mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
DEVOPS-829 format Timer as summary/histogram type (#893)
This commit is contained in:
parent
114c02bf46
commit
81b06d6ece
2 changed files with 8 additions and 11 deletions
|
|
@ -27,7 +27,6 @@ import (
|
|||
|
||||
var (
|
||||
typeGaugeTpl = "# TYPE %s gauge\n"
|
||||
typeCounterTpl = "# TYPE %s counter\n"
|
||||
typeSummaryTpl = "# TYPE %s summary\n"
|
||||
keyValueTpl = "%s %v\n\n"
|
||||
keyCounterTpl = "%s %v\n"
|
||||
|
|
@ -82,11 +81,16 @@ func (c *collector) addMeter(name string, m metrics.Meter) {
|
|||
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.writeCounter(name, m.Count())
|
||||
|
||||
var sum float64 = 0
|
||||
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
|
||||
for i := range pv {
|
||||
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
||||
sum += ps[i]
|
||||
}
|
||||
|
||||
c.writeSummarySum(name, fmt.Sprintf("%f", sum))
|
||||
c.writeSummaryCounter(name, len(ps))
|
||||
c.buff.WriteRune('\n')
|
||||
}
|
||||
|
||||
|
|
@ -118,12 +122,6 @@ func (c *collector) writeGaugeCounter(name string, value interface{}) {
|
|||
c.buff.WriteString(fmt.Sprintf(keyValueTpl, name, value))
|
||||
}
|
||||
|
||||
func (c *collector) writeCounter(name string, value interface{}) {
|
||||
name = mutateKey(name + "_count")
|
||||
c.buff.WriteString(fmt.Sprintf(typeCounterTpl, name))
|
||||
c.buff.WriteString(fmt.Sprintf(keyValueTpl, name, value))
|
||||
}
|
||||
|
||||
func (c *collector) writeSummaryCounter(name string, value interface{}) {
|
||||
name = mutateKey(name + "_count")
|
||||
c.buff.WriteString(fmt.Sprintf(keyCounterTpl, name, value))
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ test_histogram_count 6
|
|||
# TYPE test_meter gauge
|
||||
test_meter 9999999
|
||||
|
||||
# TYPE test_timer_count counter
|
||||
test_timer_count 6
|
||||
|
||||
# TYPE test_timer summary
|
||||
test_timer {quantile="0.5"} 2.25e+07
|
||||
test_timer {quantile="0.75"} 4.8e+07
|
||||
|
|
@ -90,6 +87,8 @@ test_timer {quantile="0.95"} 1.2e+08
|
|||
test_timer {quantile="0.99"} 1.2e+08
|
||||
test_timer {quantile="0.999"} 1.2e+08
|
||||
test_timer {quantile="0.9999"} 1.2e+08
|
||||
test_timer_sum 550500000.000000
|
||||
test_timer_count 6
|
||||
|
||||
# TYPE test_resetting_timer summary
|
||||
test_resetting_timer {quantile="0.50"} 12000000
|
||||
|
|
|
|||
Loading…
Reference in a new issue