diff options
author | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-06-04 18:05:16 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-06-04 18:05:16 +0800 |
commit | be2aec092d9c24c24b8d22d684ed0d11653c3cfc (patch) | |
tree | 74db6c965c6c0d8c235b92710bdacc8fb95ba309 /metrics/exp/exp.go | |
parent | 143c4341d8a2231deade6d7341c668d609bd3486 (diff) | |
download | dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.tar dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.tar.gz dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.tar.bz2 dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.tar.lz dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.tar.xz dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.tar.zst dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.zip |
metrics: expvar support for ResettingTimer (#16878)
* metrics: expvar support for ResettingTimer
* metrics: use integers for percentiles; remove Overall
* metrics: fix edge-case panic for index-out-of-range
Diffstat (limited to 'metrics/exp/exp.go')
-rw-r--r-- | metrics/exp/exp.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/metrics/exp/exp.go b/metrics/exp/exp.go index c19d00a94..625ffd4e8 100644 --- a/metrics/exp/exp.go +++ b/metrics/exp/exp.go @@ -134,6 +134,17 @@ func (exp *exp) publishTimer(name string, metric metrics.Timer) { exp.getFloat(name + ".mean-rate").Set(t.RateMean()) } +func (exp *exp) publishResettingTimer(name string, metric metrics.ResettingTimer) { + t := metric.Snapshot() + ps := t.Percentiles([]float64{50, 75, 95, 99}) + exp.getInt(name + ".count").Set(int64(len(t.Values()))) + exp.getFloat(name + ".mean").Set(t.Mean()) + exp.getInt(name + ".50-percentile").Set(ps[0]) + exp.getInt(name + ".75-percentile").Set(ps[1]) + exp.getInt(name + ".95-percentile").Set(ps[2]) + exp.getInt(name + ".99-percentile").Set(ps[3]) +} + func (exp *exp) syncToExpvar() { exp.registry.Each(func(name string, i interface{}) { switch i.(type) { @@ -149,6 +160,8 @@ func (exp *exp) syncToExpvar() { exp.publishMeter(name, i.(metrics.Meter)) case metrics.Timer: exp.publishTimer(name, i.(metrics.Timer)) + case metrics.ResettingTimer: + exp.publishResettingTimer(name, i.(metrics.ResettingTimer)) default: panic(fmt.Sprintf("unsupported type for '%s': %T", name, i)) } |