Refactor metric collection
This commit is contained in:
@@ -60,8 +60,11 @@ func (rl *rushlink) metricsMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srw := statusResponseWriter{Inner: w}
|
||||
next.ServeHTTP(&srw, r)
|
||||
|
||||
status := strconv.Itoa(srw.StatusCode)
|
||||
metricRequestsTotalCounter.WithLabelValues(status, r.Method).Inc()
|
||||
labels := map[string]string{"code": status, "method": r.Method}
|
||||
// Update requests counter metric
|
||||
metricRequestsTotalCounter.With(labels).Inc()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user