mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
metrics: Init -> Enable
This commit is contained in:
parent
9e22de7c47
commit
df9fdbc58a
5 changed files with 11 additions and 13 deletions
|
|
@ -1973,7 +1973,7 @@ func SetupMetrics(cfg *metrics.Config) {
|
|||
if !cfg.Enabled {
|
||||
return
|
||||
}
|
||||
metrics.Init(true)
|
||||
metrics.Enable()
|
||||
log.Info("Enabling metrics collection")
|
||||
var (
|
||||
enableExport = cfg.EnableInfluxDB
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import (
|
|||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
metrics.Init(true)
|
||||
metrics.Enable()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,17 +22,12 @@ func Enabled() bool {
|
|||
return metricsEnabled
|
||||
}
|
||||
|
||||
// Init enables the metrics system.
|
||||
// Enable enables the metrics system.
|
||||
// The Enabled-flag is expected to be set, once, during startup, but toggling off and on
|
||||
// is not supported: YMMV.
|
||||
// Init is not safe to call concurrently. It has no effect if it was already called.
|
||||
func Init(enabled bool) {
|
||||
metricsEnabled = enabled
|
||||
if initRan {
|
||||
return
|
||||
}
|
||||
initRan = true
|
||||
// TODO: Maybe start the ticker for exp delays, and things like that.
|
||||
// is not supported,
|
||||
// Enable is not safe to call concurrently. It has no effect if it was already called.
|
||||
func Enable() {
|
||||
metricsEnabled = true
|
||||
}
|
||||
|
||||
var threadCreateProfile = pprof.Lookup("threadcreate")
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
metrics.Init(true)
|
||||
metrics.Enable()
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ func (t *ResettingTimer) Time(f func()) {
|
|||
|
||||
// Record the duration of an event.
|
||||
func (t *ResettingTimer) Update(d time.Duration) {
|
||||
if !metricsEnabled {
|
||||
return
|
||||
}
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
t.values = append(t.values, int64(d))
|
||||
|
|
|
|||
Loading…
Reference in a new issue