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