Skip to content

Commit

Permalink
Fix prom request metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Jan 3, 2021
1 parent 58c6a7b commit 63b98f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ var (
requestCount = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "wtf_http_request_count",
Help: "Total number of requests by route",
}, []string{"route"})
}, []string{"method", "path"})

requestSeconds = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "wtf_http_request_seconds",
Help: "Total amount of request time by route, in seconds",
}, []string{"route"})
}, []string{"method", "path"})
)

// ShutdownTimeout is the time given for outstanding requests to finish before shutdown.
Expand Down Expand Up @@ -378,8 +378,8 @@ func trackMetrics(next http.Handler) http.Handler {

// Track total time unless it is the WebSocket endpoint for events.
if tmpl != "" && tmpl != "/events" {
requestCount.WithLabelValues(tmpl).Inc()
requestSeconds.WithLabelValues(tmpl).Add(float64(time.Since(t).Seconds()))
requestCount.WithLabelValues(r.Method, tmpl).Inc()
requestSeconds.WithLabelValues(r.Method, tmpl).Add(float64(time.Since(t).Seconds()))
}
})
}
Expand Down

0 comments on commit 63b98f9

Please sign in to comment.