X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=api%2Fmetrics.go;fp=api%2Fmetrics.go;h=0000000000000000000000000000000000000000;hb=d09b7a78d44dc259725902b8141cdba0d716b121;hp=4e95b52311f88b618d716100848915863a61112a;hpb=ee01d543fdfe1fd0a4d548965c66f7923ea7b062;p=bytom%2Fvapor.git diff --git a/api/metrics.go b/api/metrics.go deleted file mode 100644 index 4e95b523..00000000 --- a/api/metrics.go +++ /dev/null @@ -1,32 +0,0 @@ -package api - -import ( - "net/http" - "sync" - "time" - - "github.com/vapor/metrics" -) - -var ( - latencyMu sync.Mutex - latencies = map[string]*metrics.RotatingLatency{} -) - -// latency returns a rotating latency histogram for the given request. -func latency(tab *http.ServeMux, req *http.Request) *metrics.RotatingLatency { - latencyMu.Lock() - defer latencyMu.Unlock() - if l := latencies[req.URL.Path]; l != nil { - return l - } - // Create a histogram only if the path is legit. - if _, pat := tab.Handler(req); pat == req.URL.Path { - d := 100 * time.Millisecond - l := metrics.NewRotatingLatency(5, d) - latencies[req.URL.Path] = l - metrics.PublishLatency(req.URL.Path, l) - return l - } - return nil -}