From e34a8cf79b386355d45df3135d659cae65df207c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Tue, 11 Jun 2024 14:12:12 +0300 Subject: [PATCH] feat(prometheus): collect timer.Total() (#817) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Péter Garamvölgyi --- metrics/prometheus/collector.go | 1 + metrics/prometheus/collector_test.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/metrics/prometheus/collector.go b/metrics/prometheus/collector.go index 78ed2ae283..4ec20b37fe 100644 --- a/metrics/prometheus/collector.go +++ b/metrics/prometheus/collector.go @@ -77,6 +77,7 @@ func (c *collector) addTimer(name string, m metrics.Timer) { pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999} ps := m.Percentiles(pv) c.writeSummaryCounter(name, m.Count()) + c.writeSummaryCounter(mutateKey(name+"_total"), m.Total().Nanoseconds()) c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name))) for i := range pv { c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i]) diff --git a/metrics/prometheus/collector_test.go b/metrics/prometheus/collector_test.go index 9e27311418..afbd863101 100644 --- a/metrics/prometheus/collector_test.go +++ b/metrics/prometheus/collector_test.go @@ -84,6 +84,9 @@ test_meter 9999999 # TYPE test_timer_count counter test_timer_count 6 +# TYPE test_timer_total_count counter +test_timer_total_count 230000000 + # TYPE test_timer summary test_timer {quantile="0.5"} 2.25e+07 test_timer {quantile="0.75"} 4.8e+07