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
This commit is contained in:
Anton Evangelatov
2018-06-04 13:05:16 +03:00
committed by Péter Szilágyi
parent 143c4341d8
commit be2aec092d
4 changed files with 154 additions and 1 deletions

View File

@ -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]