-
Notifications
You must be signed in to change notification settings - Fork 275
chore(metrics): use geth metrics package and delete local metrics #1422
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
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8ecc73c
chore(metrics): use libevm metrics package and delete local metrics
qdm12 d2ca841
tests: only enable metrics and revert to disable if already disabled
qdm12 00865c2
Enable metrics by default with init block
qdm12 7b3611a
Change copyright notice from 2025 to 2021-2025
qdm12 51d7255
Enable libevm metrics in initializeMetrics
qdm12 3a95319
`testutils.WithMetrics` function in plugin/evm
qdm12 6e58856
metrics/prometheus: add test cases for full coverage
qdm12 4949b7d
metrics/prometheus: add metric name to error wrappings
qdm12 d03d034
Minor changes
qdm12 bd8a136
Enforce testutils package is only imported by test files outside plug…
qdm12 0183ff5
Rework regex matching for lint_allowed_geth_imports.sh
qdm12 29e39f0
Rework `TestMustNotImport` to check for imports in non test code
qdm12 3672a2e
Add comment on metrics.Enabled = true in `initializeMetrics`
qdm12 4e9cf9e
Clarify testutils package comment
qdm12 a7a8c24
Skip nil metric types
qdm12 c6b2e22
TestGatherer_Gather tests nil metrics
qdm12 8207254
Remove restrictions on plugin/evm/testutils package imports
qdm12 c89a5a5
Move plugin/evm/testutils to internal/testutils
qdm12 710f0ca
Add mutex for WithMetrics call
qdm12 abb2a70
Improve Registry comment
qdm12 81c7f8a
Improve readability of Gather() body for error handling
qdm12 4004860
Use testutils.WithMetrics in TestGatherer_Gather
qdm12 86e1086
Use sentinel error for metric type not supported
qdm12 0c9f6df
Add missing copyright notice to testutils/metrics.go
qdm12 2166bea
registerNilMetrics function
qdm12 bcc3919
Add context to require.NoError in test
qdm12 2ce6cfa
Replace Registry comment with interface assertion
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
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
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
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
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
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,30 @@ | ||
// (c) 2024-2025, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package testutils | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/metrics" | ||
) | ||
|
||
var metricsLock sync.Mutex | ||
|
||
// WithMetrics enables go-ethereum metrics globally for the test. | ||
// If the [metrics.Enabled] is already true, nothing is done. | ||
// Otherwise, it is set to true and is reverted to false when the test finishes. | ||
func WithMetrics(t *testing.T) { | ||
metricsLock.Lock() | ||
t.Cleanup(func() { | ||
metricsLock.Unlock() | ||
}) | ||
if metrics.Enabled { | ||
return | ||
} | ||
metrics.Enabled = true | ||
t.Cleanup(func() { | ||
metrics.Enabled = false | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.