-
Notifications
You must be signed in to change notification settings - Fork 159
fix(metrics): avoid conflicts between coreth and libevm
#860
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
Parent:
chore(all): libevm phase 2.5
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
077180b
refactor: globally replace `metrics.New*()` with `metrics.GetOrRegist…
ARR4N 1eca00d
fix: force `libevm` metrics registration to be first
ARR4N d118eef
chore: placate the linter
ARR4N d3e94c1
fix: override `core` timer metrics as counters
ARR4N 6cc5371
Revert "chore: placate the linter"
ARR4N b6c69ed
chore: linter allows `_` importing all `libevm` packages
ARR4N c3ba2c1
chore: placate `shellcheck`
ARR4N f5e47e8
fix(core): ignore `libevm/core` leaking go routine
ARR4N 2be0957
chore: correct copyright header on new file
ARR4N 8801ffd
doc: comment re potential merge conflicts and the changes made
ARR4N c3f1957
refactor: split `GetOrRegister()` and type checking off single line
ARR4N a8839a8
Merge branch 'libevm' into arr4n/metrics-avoid-conflicts
ARR4N File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // (c) 2025, Ava Labs, Inc. | ||
| package core | ||
|
|
||
| import "github.com/ava-labs/libevm/metrics" | ||
|
|
||
| // getOrOverrideAsRegisteredCounter searches for a metric already registered | ||
| // with`name`. If a metric is found and it is a Counter, it is returned. If a | ||
| // metric is found and it is not a Counter, it is unregistered and replaced with | ||
| // a new registered Counter. If no metric is found, a new Counter is constructed | ||
| // and registered. | ||
| // | ||
| // This is necessary for a metric defined in libevm with the same name but a | ||
| // different type to what we expect. | ||
ARR4N marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| func getOrOverrideAsRegisteredCounter(name string, r metrics.Registry) metrics.Counter { | ||
| if r == nil { | ||
| r = metrics.DefaultRegistry | ||
| } | ||
| if c, ok := r.GetOrRegister(name, metrics.NewCounter).(metrics.Counter); ok { | ||
ARR4N marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return c | ||
| } | ||
| r.Unregister(name) | ||
| return metrics.NewRegisteredCounter(name, r) | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.