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 libevm metrics package and delete local metrics #745

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

Conversation

qdm12
Copy link
Collaborator

@qdm12 qdm12 commented Jan 13, 2025

ℹ️ pretty much copy pasta of ava-labs/subnet-evm#1422

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:

  1. All files in metrics are deleted EXCEPT:
    • metrics/prometheus/prometheus.go + init block added to set the metrics enabled by default
    • metrics/prometheus/prometheus_test.go
    • metrics/prometheus/interfaces.go (new file added whilst refactoring)
    • go-ethereum's metrics.Enabled is set to true in initializeMetrics
  2. Refactoring and fixes were done in some intermediary step (in chore(metrics/prometheus): add files needed for coreth and subnet-evm libevm#103), so I decided to bring this over here so it doesn't get trashed. I can split it in another PR if you feel it's necessary.

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 force-pushed the qdm12/libevm/metrics branch from 2164d72 to caf4d61 Compare January 13, 2025 15:23
metrics/prometheus/prometheus.go Outdated Show resolved Hide resolved
metrics/prometheus/prometheus.go Outdated Show resolved Hide resolved
@@ -34,8 +34,7 @@ import (
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/eth"
"github.com/ava-labs/coreth/eth/ethconfig"
"github.com/ava-labs/coreth/metrics"
corethPrometheus "github.com/ava-labs/coreth/metrics/prometheus"
corethprometheus "github.com/ava-labs/coreth/metrics/prometheus"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nit I took the liberty to have this all lowercase, I believe this is Go convention for package name aliases (correct me if I'm wrong!)

@@ -636,7 +636,7 @@ func (vm *VM) initializeMetrics() error {
return nil
}

gatherer := corethPrometheus.Gatherer(metrics.DefaultRegistry)
gatherer := corethprometheus.NewGatherer(metrics.DefaultRegistry)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nit I took the liberty (again) to rename Gatherer to NewGatherer in order to export gatherer as Gatherer and return a *Gatherer from NewGatherer to satisfy the "return concrete types" concept

warp/handlers/signature_request_test.go Outdated Show resolved Hide resolved
Comment on lines 194 to 195
default:
return nil, fmt.Errorf("metric type is not supported: %T", metric)
Copy link
Collaborator Author

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.

metrics/prometheus/prometheus_test.go Outdated Show resolved Hide resolved
@qdm12 qdm12 marked this pull request as ready for review January 13, 2025 16:25
@qdm12 qdm12 requested review from ceyonur, darioush and a team as code owners January 13, 2025 16:25
@qdm12 qdm12 force-pushed the qdm12/libevm/metrics branch from 2d6a89e to 624eafc Compare January 13, 2025 17:05
@qdm12 qdm12 force-pushed the qdm12/libevm/metrics branch from 624eafc to d7b1c12 Compare January 14, 2025 11:16
@qdm12 qdm12 force-pushed the qdm12/libevm/metrics branch from d7b1c12 to 3e3d44c Compare January 14, 2025 12:16
@darioush
Copy link
Collaborator

some review suggestions: #747

darioush
darioush previously approved these changes Jan 14, 2025
Copy link
Collaborator Author

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

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

Self review

plugin/evm/config/config.go Outdated Show resolved Hide resolved
metrics/prometheus/prometheus_test.go Outdated Show resolved Hide resolved
metrics/prometheus/prometheus.go Outdated Show resolved Hide resolved
metrics/prometheus/prometheus.go Show resolved Hide resolved
metrics/prometheus/prometheus.go Outdated Show resolved Hide resolved
metrics/prometheus/prometheus.go Show resolved Hide resolved
metrics/prometheus/prometheus.go Outdated Show resolved Hide resolved
metrics/prometheus/prometheus.go Outdated Show resolved Hide resolved
metrics/prometheus/prometheus_test.go Outdated Show resolved Hide resolved
plugin/evm/vm.go Outdated Show resolved Hide resolved
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.

2 participants