-
Notifications
You must be signed in to change notification settings - Fork 244
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
chore(metrics): use geth metrics package and delete local metrics #1422
base: master
Are you sure you want to change the base?
Conversation
34e9afd
to
8c8514c
Compare
metrics/prometheus/prometheus.go
Outdated
default: | ||
return nil, fmt.Errorf("metric type is not supported: %T", metric) |
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 took the liberty to change this to return an error (instead of silently ignoring it) on an unsupported type to prevent in the future to define new types and forget to add the implementation in the switch here.
7c08815
to
15866c8
Compare
15866c8
to
769d5fc
Compare
- 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]>
Signed-off-by: Quentin McGaw <[email protected]>
- add exported comments - rename `g` to `gatherer` in test - Format copyright as it as ™️ - Remove TODO
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.
Looks good! The subnet dashboard is now populated with metrics for the load test e2e job:
A random PR doesn't show any metrics on the subnets dashboard for the same job:
Ah, let me check if I can revert it to no-metric, and open another PR (based off this one I suppose) to enable metrics. |
Working as expected, this is good to go (same as ava-labs/coreth#745), just need reviews 😉 |
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.
some optional suggestions
Signed-off-by: Quentin McGaw <[email protected]>
// - a non-test file imports the testutils package | ||
func TestMustNotImport(t *testing.T) { | ||
prodOnly := false | ||
checkNotImporting(t, "../", prodOnly, "testutils should only be used outside plugin/evm") |
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.
why do we have such limitation? Does that mean we can't use this pkg in plugin/evm test files?
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.
See this comment. TLDR:
- this testutils package is only to limit diffs in geth code
- (subjective) we should prefer to copy paste test helping utilities, to reduce package dependencies and possible cycle import issues
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 think we should limit this pkg like that. if we nee such a pkg it should be in internal if possible and under a different pkg than plugin/evm. I think it should be sufficient to check this is not imported in any prod code, no?
I'm fine with copy pasting WithMetrics
if we feel like it's best not to import metrics
here.
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.
thinking again, having a testutils
package actually indicates this should be not called from prod code. So not sure if there is any point to strict that down too much.
metrics.NilGauge, metrics.NilGaugeFloat64, metrics.NilGaugeInfo, | ||
metrics.NilHealthcheck, metrics.NilHistogram, metrics.NilMeter, | ||
metrics.NilResettingTimer, metrics.NilSample, metrics.NilTimer: | ||
return nil, fmt.Errorf("%w: %q metric is nil", errMetricSkip, name) |
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.
if we're going to skip this, can't we just return nil err?
}}, | ||
}, nil | ||
default: | ||
return nil, fmt.Errorf("metric %q: type is not supported: %T", name, metric) |
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.
this won't cause any unknown geth metric type to break this, right? (e.g a new upstream type in the future)
// - a non-test file imports the testutils package | ||
func TestMustNotImport(t *testing.T) { | ||
prodOnly := false | ||
checkNotImporting(t, "../", prodOnly, "testutils should only be used outside plugin/evm") |
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 think we should limit this pkg like that. if we nee such a pkg it should be in internal if possible and under a different pkg than plugin/evm. I think it should be sufficient to check this is not imported in any prod code, no?
I'm fine with copy pasting WithMetrics
if we feel like it's best not to import metrics
here.
// - a non-test file imports the testutils package | ||
func TestMustNotImport(t *testing.T) { | ||
prodOnly := false | ||
checkNotImporting(t, "../", prodOnly, "testutils should only be used outside plugin/evm") |
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.
thinking again, having a testutils
package actually indicates this should be not called from prod code. So not sure if there is any point to strict that down too much.
Why this should be merged
Contribution to the libevm effort.
Note there are the same changes for both coreth and subnet-evm, but they should not be part of libevm since these are extra features specific to subnet-evm/coreth, even if they're the same for both.
How this works
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?
Not really, since it should not change anything 🙏