diff options
Diffstat (limited to 'system/api/analytics/init.go')
-rw-r--r-- | system/api/analytics/init.go | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/system/api/analytics/init.go b/system/api/analytics/init.go index eaac246..3af1407 100644 --- a/system/api/analytics/init.go +++ b/system/api/analytics/init.go @@ -27,25 +27,20 @@ var ( ) // Record queues an apiRequest for metrics -func Record(next http.HandlerFunc) http.HandlerFunc { - return func(res http.ResponseWriter, req *http.Request) { - external := strings.Contains(req.URL.Path, "/external/") - - r := apiRequest{ - URL: req.URL.String(), - Method: req.Method, - Origin: req.Header.Get("Origin"), - RemoteAddr: req.RemoteAddr, - Timestamp: time.Now().Unix() * 1000, - External: external, - } - - // put r on buffered recordChan to take advantage of batch insertion in DB - recordChan <- r - - next.ServeHTTP(res, req) +func Record(req *http.Request) { + external := strings.Contains(req.URL.Path, "/external/") + + r := apiRequest{ + URL: req.URL.String(), + Method: req.Method, + Origin: req.Header.Get("Origin"), + RemoteAddr: req.RemoteAddr, + Timestamp: time.Now().Unix() * 1000, + External: external, } + // put r on buffered recordChan to take advantage of batch insertion in DB + recordChan <- r } // Close exports the abillity to close our db file. Should be called with defer |