web: deduplicate handler label for HTTP metrics (#4752)
* web: deduplicate handler label for HTTP metrics Signed-off-by: Simon Pasquier <spasquie@redhat.com> * remove instrumentHandlerFunc Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
61cf4365d6
commit
632626b553
|
@ -191,6 +191,12 @@ type Options struct {
|
|||
RemoteReadConcurrencyLimit int
|
||||
}
|
||||
|
||||
func instrumentHandlerWithPrefix(prefix string) func(handlerName string, handler http.HandlerFunc) http.HandlerFunc {
|
||||
return func(handlerName string, handler http.HandlerFunc) http.HandlerFunc {
|
||||
return instrumentHandler(prefix+handlerName, handler)
|
||||
}
|
||||
}
|
||||
|
||||
func instrumentHandler(handlerName string, handler http.HandlerFunc) http.HandlerFunc {
|
||||
return promhttp.InstrumentHandlerDuration(
|
||||
requestDuration.MustCurryWith(prometheus.Labels{"handler": handlerName}),
|
||||
|
@ -459,7 +465,7 @@ func (h *Handler) Run(ctx context.Context) error {
|
|||
mux := http.NewServeMux()
|
||||
mux.Handle("/", h.router)
|
||||
|
||||
av1 := route.New().WithInstrumentation(instrumentHandler)
|
||||
av1 := route.New().WithInstrumentation(instrumentHandlerWithPrefix("/api/v1"))
|
||||
h.apiV1.Register(av1)
|
||||
apiPath := "/api"
|
||||
if h.options.RoutePrefix != "/" {
|
||||
|
|
Loading…
Reference in New Issue