From bde52a911eb5bfec6a4f40e1b633a33af4693080 Mon Sep 17 00:00:00 2001 From: Catherine Date: Sat, 30 May 2026 15:44:25 +0000 Subject: [PATCH] Limit cardinality for `git_pages_http_request_*` metrics. V12-Ref: F-77243 --- src/observe.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/observe.go b/src/observe.go index a7210ed..2fbfba4 100644 --- a/src/observe.go +++ b/src/observe.go @@ -11,6 +11,7 @@ import ( "net/http" "os" "runtime/debug" + "slices" "sync" "time" @@ -130,11 +131,15 @@ func ObserveHTTPHandler(handler http.Handler) http.Handler { next.ServeHTTP(&ow, r) duration := time.Since(start) + method := r.Method + if !slices.Contains([]string{"HEAD", "GET", "PUT", "PATCH", "DELETE", "POST"}, method) { + method = "!OTHER" + } httpRequestCount. - With(prometheus.Labels{"method": r.Method, "code": fmt.Sprintf("%d", ow.status)}). + With(prometheus.Labels{"method": method, "code": fmt.Sprintf("%d", ow.status)}). Inc() httpRequestDurationSeconds. - With(prometheus.Labels{"method": r.Method}). + With(prometheus.Labels{"method": method}). Observe(duration.Seconds()) }) }(handler)