From bfee85fa7be24d61ebb07e89e27d4c7230105ab2 Mon Sep 17 00:00:00 2001 From: directduck Date: Fri, 31 Oct 2025 13:45:35 +0300 Subject: [PATCH] Fix metrics round tripper --- client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 80003c6..67ca980 100644 --- a/client.go +++ b/client.go @@ -76,10 +76,12 @@ func (m *metricsRoundTripper) RoundTrip(req *http.Request) (*http.Response, erro clientInflights.With(labels).Dec() duration := time.Since(start).Seconds() - labels["method"] = req.Method + var code string if resp != nil { - labels["code"] = strconv.Itoa(resp.StatusCode) + code = strconv.Itoa(resp.StatusCode) } + labels["code"] = code + labels["method"] = req.Method clientRequests.With(labels).Inc() clientDurations.With(labels).Observe(duration)