mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
metrics: eagerly construct metrics objects
This commit is contained in:
parent
8b9f2d4e36
commit
a6b078f36a
8 changed files with 9 additions and 10 deletions
|
|
@ -10,7 +10,7 @@ func GetOrRegisterCounter(name string, r Registry) *Counter {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, NewCounter).(*Counter)
|
return r.GetOrRegister(name, NewCounter()).(*Counter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCounter constructs a new Counter.
|
// NewCounter constructs a new Counter.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ func GetOrRegisterCounterFloat64(name string, r Registry) *CounterFloat64 {
|
||||||
if nil == r {
|
if nil == r {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, NewCounterFloat64).(*CounterFloat64)
|
return r.GetOrRegister(name, NewCounterFloat64()).(*CounterFloat64)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCounterFloat64 constructs a new CounterFloat64.
|
// NewCounterFloat64 constructs a new CounterFloat64.
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ func GetOrRegisterGauge(name string, r Registry) *Gauge {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, NewGauge).(*Gauge)
|
return r.GetOrRegister(name, NewGauge()).(*Gauge)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGauge constructs a new Gauge.
|
// NewGauge constructs a new Gauge.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ func GetOrRegisterHistogram(name string, r Registry, s Sample) Histogram {
|
||||||
if nil == r {
|
if nil == r {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, func() Histogram { return NewHistogram(s) }).(Histogram)
|
return r.GetOrRegister(name, NewHistogram(s)).(Histogram)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOrRegisterHistogramLazy returns an existing Histogram or constructs and
|
// GetOrRegisterHistogramLazy returns an existing Histogram or constructs and
|
||||||
|
|
@ -35,7 +35,7 @@ func GetOrRegisterHistogramLazy(name string, r Registry, s func() Sample) Histog
|
||||||
if nil == r {
|
if nil == r {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, func() Histogram { return NewHistogram(s()) }).(Histogram)
|
return r.GetOrRegister(name, NewHistogram(s())).(Histogram)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHistogram constructs a new StandardHistogram from a Sample.
|
// NewHistogram constructs a new StandardHistogram from a Sample.
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ func GetOrRegisterMeter(name string, r Registry) *Meter {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, NewMeter).(*Meter)
|
return r.GetOrRegister(name, NewMeter()).(*Meter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMeter constructs a new Meter and launches a goroutine.
|
// NewMeter constructs a new Meter and launches a goroutine.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ func GetOrRegisterResettingTimer(name string, r Registry) *ResettingTimer {
|
||||||
if nil == r {
|
if nil == r {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, NewResettingTimer).(*ResettingTimer)
|
return r.GetOrRegister(name, NewResettingTimer()).(*ResettingTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRegisteredResettingTimer constructs and registers a new ResettingTimer.
|
// NewRegisteredResettingTimer constructs and registers a new ResettingTimer.
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@ func getOrRegisterRuntimeHistogram(name string, scale float64, r Registry) *runt
|
||||||
if r == nil {
|
if r == nil {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
constructor := func() Histogram { return newRuntimeHistogram(scale) }
|
return r.GetOrRegister(name, newRuntimeHistogram(scale)).(*runtimeHistogram)
|
||||||
return r.GetOrRegister(name, constructor).(*runtimeHistogram)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// runtimeHistogram wraps a runtime/metrics histogram.
|
// runtimeHistogram wraps a runtime/metrics histogram.
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ func GetOrRegisterTimer(name string, r Registry) *Timer {
|
||||||
if nil == r {
|
if nil == r {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
}
|
}
|
||||||
return r.GetOrRegister(name, NewTimer).(*Timer)
|
return r.GetOrRegister(name, NewTimer()).(*Timer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCustomTimer constructs a new Timer from a Histogram and a Meter.
|
// NewCustomTimer constructs a new Timer from a Histogram and a Meter.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue