Merge pull request #12472 from metalmatze/request-counter-init

web: Initialize requestCounter metrics to 0 with handler and 200 labels
This commit is contained in:
Matthias Loibl 2023-06-30 14:07:20 +02:00 committed by GitHub
commit 71d149a79f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -158,6 +158,7 @@ func (m *metrics) instrumentHandlerWithPrefix(prefix string) func(handlerName st
}
func (m *metrics) instrumentHandler(handlerName string, handler http.HandlerFunc) http.HandlerFunc {
m.requestCounter.WithLabelValues(handlerName, "200")
return promhttp.InstrumentHandlerCounter(
m.requestCounter.MustCurryWith(prometheus.Labels{"handler": handlerName}),
promhttp.InstrumentHandlerDuration(