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:
committed by
Péter Szilágyi
parent
143c4341d8
commit
be2aec092d
@ -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]
|
||||
|
Reference in New Issue
Block a user