Skip to content
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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

qdm12
Copy link
Collaborator

@qdm12 qdm12 commented Jan 13, 2025

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:

Therefore:

  • file kept and refactored metrics/prometheus/prometheus.go with the Gatherer implementation we use
  • file kept and refactored metrics/prometheus/prometheus_test.go
  • new file metrics/prometheus/interfaces.go added for refactoring
  • geth global variable metrics.Enabled is set to true in plugin/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 🙏

@qdm12 qdm12 marked this pull request as ready for review January 13, 2025 16:08
@qdm12 qdm12 requested review from ceyonur, darioush and a team as code owners January 13, 2025 16:08
@qdm12 qdm12 force-pushed the qdm12/libevm/metrics branch from 7c08815 to 15866c8 Compare January 15, 2025 11:15
@qdm12 qdm12 requested a review from darioush January 15, 2025 11:40
darioush
darioush previously approved these changes Jan 23, 2025
@qdm12 qdm12 changed the title chore(metrics): use libevm metrics package and delete local metrics chore(metrics): use geth metrics package and delete local metrics Jan 27, 2025
@qdm12 qdm12 force-pushed the qdm12/libevm/metrics branch from 15866c8 to 769d5fc Compare January 27, 2025 12:50
@qdm12
Copy link
Collaborator Author

qdm12 commented Feb 10, 2025

Working as expected, this is good to go (same as ava-labs/coreth#745), just need reviews 😉

@qdm12 qdm12 enabled auto-merge (squash) February 10, 2025 07:50
@qdm12 qdm12 requested review from darioush and maru-ava February 10, 2025 07:50
maru-ava
maru-ava previously approved these changes Feb 10, 2025
darioush
darioush previously approved these changes Feb 11, 2025
Copy link
Collaborator

@darioush darioush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some optional suggestions

@qdm12 qdm12 dismissed stale reviews from darioush and maru-ava via e389c7f February 17, 2025 13:02
@qdm12 qdm12 requested a review from ceyonur February 17, 2025 14:47
darioush
darioush previously approved these changes Feb 18, 2025
@qdm12 qdm12 added the DO NOT MERGE This PR is not meant to be merged in its current state label Feb 20, 2025
@qdm12 qdm12 removed the DO NOT MERGE This PR is not meant to be merged in its current state label Feb 24, 2025
@qdm12 qdm12 requested a review from ceyonur February 24, 2025 15:45
}},
}, nil
default:
return nil, fmt.Errorf("metric %q: type is not supported: %T", name, metric)
Copy link
Collaborator

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it break it? This would show in the CI right, and we should add the type to our switch case and either handle it or explicitly ignore it, I think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be ok if this is going to be called with any unknown metric in the first metricFamily() call (i.e right after when we spin up the node). My question is if there is any possibility that any potential unknown upstream metric is registered in the runtime in a more rare case that CI won't immediately catch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only place that gatherer is registered is:

if err := vm.ctx.Metrics.Register(ethMetricsPrefix, gatherer); err != nil {

Which registers it to avalanchego's multi gatherer and all errors are checked/none-are-discarded.

Maybe it's not covered by tests, but it should definitely show up in e2e tests (and, if not, we would have an error handling problem in avalanchego).

@qdm12 qdm12 requested a review from ceyonur March 11, 2025 11:39
Copy link
Collaborator

@ceyonur ceyonur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes lgtm, just a small concern/question with potential unknown metrics in upstream.

@qdm12 qdm12 requested a review from darioush March 12, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants