mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
parent
6e5f466df9
commit
13d64fb5b5
6 changed files with 8 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
|||
// Hook go-metrics into expvar
|
||||
// on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
|
||||
|
||||
package exp
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func NewRegisteredGaugeInfo(name string, r Registry) *GaugeInfo {
|
|||
return c
|
||||
}
|
||||
|
||||
// gaugeInfoSnapshot is a read-only copy of another GaugeInfo.
|
||||
// GaugeInfoSnapshot is a read-only copy of another GaugeInfo.
|
||||
type GaugeInfoSnapshot GaugeInfoValue
|
||||
|
||||
// Value returns the value at the time the snapshot was taken.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ func Log(r Registry, freq time.Duration, l Logger) {
|
|||
LogScaled(r, freq, time.Nanosecond, l)
|
||||
}
|
||||
|
||||
// Output each metric in the given registry periodically using the given
|
||||
// LogScaled outputs each metric in the given registry periodically using the given
|
||||
// logger. Print timings in `scale` units (eg time.Millisecond) rather than nanos.
|
||||
func LogScaled(r Registry, freq time.Duration, scale time.Duration, l Logger) {
|
||||
du := float64(scale)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// <https://github.com/rcrowley/go-metrics>
|
||||
//
|
||||
// Coda Hale's original work: <https://github.com/codahale/metrics>
|
||||
|
||||
package metrics
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -53,14 +53,14 @@ func (t *ResettingTimer) Snapshot() *ResettingTimerSnapshot {
|
|||
return snapshot
|
||||
}
|
||||
|
||||
// Record the duration of the execution of the given function.
|
||||
// Time records the duration of the execution of the given function.
|
||||
func (t *ResettingTimer) Time(f func()) {
|
||||
ts := time.Now()
|
||||
f()
|
||||
t.Update(time.Since(ts))
|
||||
}
|
||||
|
||||
// Record the duration of an event.
|
||||
// Update records the duration of an event.
|
||||
func (t *ResettingTimer) Update(d time.Duration) {
|
||||
if !metricsEnabled {
|
||||
return
|
||||
|
|
@ -71,7 +71,7 @@ func (t *ResettingTimer) Update(d time.Duration) {
|
|||
t.sum += int64(d)
|
||||
}
|
||||
|
||||
// Record the duration of an event that started at a time and ends now.
|
||||
// UpdateSince records the duration of an event that started at a time and ends now.
|
||||
func (t *ResettingTimer) UpdateSince(ts time.Time) {
|
||||
t.Update(time.Since(ts))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// Output each metric in the given registry to syslog periodically using
|
||||
// Syslog outputs each metric in the given registry to syslog periodically using
|
||||
// the given syslogger.
|
||||
func Syslog(r Registry, d time.Duration, w *syslog.Writer) {
|
||||
for range time.Tick(d) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue