metrics: add missing ResettingTimer case in GetAll() (#33749)

Follow-up to https://github.com/ethereum/go-ethereum/pull/33748

Same issue - ResettingTimer can be registered via loadOrRegister() but
GetAll() silently drops it during JSON export. The prometheus exporter
handles it fine (collector.go:70), so this is just an oversight in the
JSON path.

Note: ResettingTimer.Snapshot() resets the timer by design, which is
consistent with how the prometheus exporter uses it.
This commit is contained in:
vickkkkkyy 2026-02-06 20:07:55 +08:00 committed by GitHub
parent aa457eda4b
commit 9967fb7c5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -188,6 +188,18 @@ func (r *StandardRegistry) GetAll() map[string]map[string]interface{} {
values["5m.rate"] = t.Rate5()
values["15m.rate"] = t.Rate15()
values["mean.rate"] = t.RateMean()
case *ResettingTimer:
t := metric.Snapshot()
ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
values["count"] = t.Count()
values["min"] = t.Min()
values["max"] = t.Max()
values["mean"] = t.Mean()
values["median"] = ps[0]
values["75%"] = ps[1]
values["95%"] = ps[2]
values["99%"] = ps[3]
values["99.9%"] = ps[4]
}
data[name] = values
})