Skip to content

Commit

Permalink
feat(prometheus): collect timer.Total() (#817)
Browse files Browse the repository at this point in the history
Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
  • Loading branch information
omerfirmak and Thegaram committed Jun 11, 2024
1 parent 16cbc9a commit e34a8cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions metrics/prometheus/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
3 changes: 3 additions & 0 deletions metrics/prometheus/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e34a8cf

Please sign in to comment.