From 53954090a329049b1d3b14c3122538b6f1abeb76 Mon Sep 17 00:00:00 2001 From: Tom Neuber Date: Mon, 30 Dec 2024 23:42:52 +0100 Subject: [PATCH] fix(metrics): correct cumulative count calculation --- internal/exporter/metrics.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/exporter/metrics.go b/internal/exporter/metrics.go index f672de9..ba593f8 100644 --- a/internal/exporter/metrics.go +++ b/internal/exporter/metrics.go @@ -193,15 +193,19 @@ func (m *Metrics) collectReqeustDataMetrics(ch chan<- prometheus.Metric, queue * sum += latency count++ - var cumulativeCount uint64 for _, bound := range bucketBounds { if latency <= bound { - cumulativeCount++ + buckets[bound]++ } - buckets[bound] += cumulativeCount } } + var cumulativeCount uint64 + for _, bound := range bucketBounds { + cumulativeCount += buckets[bound] + buckets[bound] = cumulativeCount + } + m.counter += uint(len(data)) ch <- prometheus.MustNewConstMetric( m.metricRequestsTotal,