8 "github.com/vapor/metrics"
13 latencies = map[string]*metrics.RotatingLatency{}
16 // latency returns a rotating latency histogram for the given request.
17 func latency(tab *http.ServeMux, req *http.Request) *metrics.RotatingLatency {
19 defer latencyMu.Unlock()
20 if l := latencies[req.URL.Path]; l != nil {
23 // Create a histogram only if the path is legit.
24 if _, pat := tab.Handler(req); pat == req.URL.Path {
25 d := 100 * time.Millisecond
26 l := metrics.NewRotatingLatency(5, d)
27 latencies[req.URL.Path] = l
28 metrics.PublishLatency(req.URL.Path, l)