From 97771b10233472e470e257b1b30e6bf4a51b02d1 Mon Sep 17 00:00:00 2001 From: aovantsev Date: Thu, 9 Oct 2025 07:31:00 +0300 Subject: [PATCH] fix prefix --- metrics.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metrics.go b/metrics.go index 1f75b06..6adc8ff 100644 --- a/metrics.go +++ b/metrics.go @@ -4,6 +4,7 @@ import ( "log" "net/http" "strconv" + "strings" "time" "github.com/gin-gonic/gin" @@ -115,7 +116,7 @@ func MetricsMiddleware() gin.HandlerFunc { httpRequestDuration.WithLabelValues(method, path).Observe(duration) // Record API-specific metrics for API routes - if c.Request.URL.Path[:4] == "/api" { + if strings.HasPrefix(c.Request.URL.Path, "/api") { apiRequestsTotal.WithLabelValues(path, method).Inc() } }