-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
metrics, cmd/geth: change init-process of metrics #30814
base: master
Are you sure you want to change the base?
Conversation
Runtime examples Load (and enable) from conf:
Load from conf, but override with commandline
Load from conf, override to disable metrics
|
value atomic.Int64 | ||
} | ||
// Gauge holds an int64 value that can be set arbitrarily. | ||
type Gauge atomic.Int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that this was changed to be just an int64
. It doesn't improve the implementation code (have to convert it at every use), and the internals are fully exposed.
It's OK to define a struct with only one field sometimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a bit inconsistent they way it is right now:
// StandardCounter is the standard implementation of a Counter and uses the
// sync/atomic package to manage a single int64 value.
type StandardCounter atomic.Int64
vs
// StandardGauge is the standard implementation of a Gauge and uses the
// sync/atomic package to manage a single int64 value.
type StandardGauge struct {
value atomic.Int64
}
So I decided to just make them identical
Starting this on both
And thus croaked on a From what I can tell at a glance, the charts seem to be working like before |
Alternative to #30781 .
This PR modifies how the metrics library handles
Enabled
: previously, the packageinit
decided whether to serve real metrics or just dummy-types.This has several drawbacks:
This PR removes the interface stuff, uses concrete types, and allows for the setting of Enabled to happen later. It is still assumed that
metrics.Enable()
is invoked fairly early on.The somewhat 'heavy' operations, such as ticking meters and exp-decay, now checks the enable-flag to prevent resource leak.
The change may be large, but it's mostly pretty trivial, and from the last time I gutted the metrics, I ensured that we have fairly good test coverage.