summaryrefslogtreecommitdiff
path: root/system/api/analytics/init.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2016-11-01 21:39:42 -0700
committerSteve Manuel <nilslice@gmail.com>2016-11-01 21:39:42 -0700
commit0f07efbf6ad59793c96fb1d7ffdd68ddff7bd7f4 (patch)
tree46889767ba216bd9cbbbc3d239dc7f88af22ebad /system/api/analytics/init.go
parent6ee469616d56b069dd68391577f0cd9411abc46a (diff)
adding analytics tracking to API calls
Diffstat (limited to 'system/api/analytics/init.go')
-rw-r--r--system/api/analytics/init.go29
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