-
Notifications
You must be signed in to change notification settings - Fork 275
chore(metrics): use libevm metrics package #1508
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- delete content of `metrics` package except `prometheus` package - only keep subnet-evm specifics in `metrics/prometheus` - Bring over refactoring and fixes done in ava-labs/libevm#103 - Bring over test refactoring done in ava-labs/libevm#103
Signed-off-by: Quentin McGaw <[email protected]>
- add exported comments - rename `g` to `gatherer` in test - Format copyright as it should be ™️ - Remove TODO
Signed-off-by: Quentin McGaw <[email protected]>
- remove non linkable prometheus.Registry
Co-authored-by: Arran Schlosberg <[email protected]> Signed-off-by: Quentin McGaw <[email protected]>
- Metrics enabled corrrectly - Remove config argument from BackendConstructor since it's no longer needed - Export newTimestampCompatError with wrapping function NewTimestampCompatErr - rlpgen supports type aliases - Better logging See original PR ava-labs/coreth#889
279bbe1
to
a6dabd3
Compare
`geth` (and hence `libevm`) global metrics tend to be created with `NewRegistered*()`, which assumes that there are no name conflicts on the same `Registry`. If there are then the second call fails silently to register the new metric. Except for in `warp` (where there won't be any conflicts) metric registration is changed globally to use `GetOrRegister*()` instead of `NewRegistered*()`. With GNU tools (not the Mac budget replacements): ```shell find -iname '*.go' -not -iwholename '*/warp/*' | xargs sed -i 's|metrics.NewRegistered|metrics.GetOrRegister|g' ``` All modified files that don't already import their `libevm` counterparts now `_` import them to force the initialisation order. The `libevm` construction with `NewRegistered*()` therefore always comes before the respective `GetOrRegister*()` so both call sites have the same metric instance. Metrics that we expect to be counters instead of timers are unregistered and newly created with the correct type, borrowing from ava-labs/libevm#159. See original PR ava-labs/coreth#860
darioush
approved these changes
Mar 31, 2025
ceyonur
approved these changes
Mar 31, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this should be merged
Use libevm/metrics instead of local subnet-evm/metrics.
This is required to be able to continue work on libevm.
(Formerly #1422 which got merged by error, big time apologies for that, and I have no idea how it happened! 🤷 😢 )
How this works
⚠️ This is blocked by a libevm upgrade (in both avalanchego and here) to have the metrics package global variable libevm bumped with theEnabled = true
in order to have global scope metrics registered as non-no-op-metrics, see ava-labs/libevm#165Enabled
global variable defaulting totrue
.Comparing the following:
master
vs corethmaster
: subnet-evm is missing the extra file https://github.com/ava-labs/coreth/blob/b6b4dfbc4bfc7f17e4cfe5f3c0fb44944176c884/metrics/init_test.go (which is present in geth as well)master
vs gethv1.13.14
: subnet-evm has many deletions, very few minor unneeded changes and the new non-conflicting filemetrics/prometheus/prometheus.go
Therefore:
metrics/prometheus/prometheus.go
with theGatherer
implementation we usemetrics/prometheus/prometheus_test.go
metrics/prometheus/interfaces.go
added for refactoringmetrics.Enabled
is set to true inplugin/evm.VM.initializeMetrics
Note for the two files refactored (with fixes as well), this was done in some intermediary step in ava-labs/libevm#103, so I decided to bring this over here so it doesn't get trashed.
How this was tested
CI passing
Need to be documented?
No
Need to update RELEASES.md?
No