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/resetting_timer.go | |
parent | 143c4341d8a2231deade6d7341c668d609bd3486 (diff) | |
download | dexon-be2aec092d9c24c24b8d22d684ed0d11653c3cfc.tar.gz 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/resetting_timer.go')
-rw-r--r-- | metrics/resetting_timer.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/metrics/resetting_timer.go b/metrics/resetting_timer.go index 57bcb3134..f33a9f8aa 100644 --- a/metrics/resetting_timer.go +++ b/metrics/resetting_timer.go @@ -210,7 +210,7 @@ func (t *ResettingTimerSnapshot) calc(percentiles []float64) { // poor man's math.Round(x): // math.Floor(x + 0.5) indexOfPerc := int(math.Floor(((abs / 100.0) * float64(count)) + 0.5)) - if pct >= 0 { + if pct >= 0 && indexOfPerc > 0 { indexOfPerc -= 1 // index offset=0 } thresholdBoundary = t.values[indexOfPerc] |