fix(metrics): correct cumulative count calculation
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Tom Neuber 2024-12-30 23:42:52 +01:00
parent 3a1e4fdc3c
commit 53954090a3
Signed by: tom
GPG key ID: F17EFE4272D89FF6

View file

@ -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,