From 5cd3c9d3b97acb2249d83c31c1c3b1788251cf6a Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:41:15 +0800 Subject: [PATCH] feat(prometheus): collect timer.Total() (#950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(prometheus): collect timer.Total() (#817) Co-authored-by: Ömer Faruk Irmak Co-authored-by: Péter Garamvölgyi --- metrics/prometheus/collector.go | 1 + metrics/prometheus/testdata/prometheus.want | 3 +++ 2 files changed, 4 insertions(+) diff --git a/metrics/prometheus/collector.go b/metrics/prometheus/collector.go index a6cbcd64a7..58bd8ffb7f 100644 --- a/metrics/prometheus/collector.go +++ b/metrics/prometheus/collector.go @@ -114,6 +114,7 @@ func (c *collector) addTimer(name string, m metrics.TimerSnapshot) { 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/testdata/prometheus.want b/metrics/prometheus/testdata/prometheus.want index 861c5f5cf0..97e51634d6 100644 --- a/metrics/prometheus/testdata/prometheus.want +++ b/metrics/prometheus/testdata/prometheus.want @@ -60,6 +60,9 @@ test_resetting_timer {quantile="0.99"} 1.2e+08 # 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