From bf3cd8e6ca2e36bbdb9b95d0aab6948aa834ae46 Mon Sep 17 00:00:00 2001 From: 4orty Date: Mon, 29 May 2023 20:28:21 +0900 Subject: [PATCH 1/2] fix double-counting bug in http_request_duration metric Signed-off-by: 4orty --- pkg/extprom/http/instrument_server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/extprom/http/instrument_server.go b/pkg/extprom/http/instrument_server.go index 6c0e626267..745a5c8af7 100644 --- a/pkg/extprom/http/instrument_server.go +++ b/pkg/extprom/http/instrument_server.go @@ -76,7 +76,7 @@ func httpInstrumentationHandler(baseLabels prometheus.Labels, metrics *defaultMe requestLabels := prometheus.Labels{"code": wd.Status(), "method": strings.ToLower(r.Method)} observer := metrics.requestDuration.MustCurryWith(baseLabels).With(requestLabels) - observer.Observe(time.Since(now).Seconds()) + requestDuration := time.Since(now).Seconds() // If we find a tracingID we'll expose it as Exemplar. var ( @@ -104,11 +104,13 @@ func httpInstrumentationHandler(baseLabels prometheus.Labels, metrics *defaultMe if traceID != "" { observer.(prometheus.ExemplarObserver).ObserveWithExemplar( - time.Since(now).Seconds(), + requestDuration, prometheus.Labels{ "traceID": traceID, }, ) + } else { + observer.Observe(requestDuration) } }), ), From f059a14fb9891bafd41cde964e7d58f3b4703c7a Mon Sep 17 00:00:00 2001 From: 4orty Date: Tue, 30 May 2023 15:45:10 +0900 Subject: [PATCH 2/2] Update Changelog Signed-off-by: 4orty --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a07702bae..02b08691fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6330](https://github.com/thanos-io/thanos/pull/6330) Store: Fix inconsistent error for series limits. - [#6342](https://github.com/thanos-io/thanos/pull/6342) Cache/Redis: Upgrade `rueidis` to v1.0.2 to to improve error handling while shrinking a redis cluster. - [#6325](https://github.com/thanos-io/thanos/pull/6325) Store: return gRPC resource exhausted error for byte limiter. +- [#6399](https://github.com/thanos-io/thanos/pull/6399) *: Fix double-counting bug in http_request_duration metric ### Changed - [#6168](https://github.com/thanos-io/thanos/pull/6168) Receiver: Make ketama hashring fail early when configured with number of nodes lower than the replication factor.