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

refactor(metrics): use default prometheus go metrics collector, and implement standard Prometheus gauges for existing metrics #2219

Merged
merged 23 commits into from
Jan 28, 2022

Conversation

timwu20
Copy link
Contributor

@timwu20 timwu20 commented Jan 20, 2022

Changes

  • Remove dot/metrics and the use of ethmetrics
  • Create internal/metrics which starts the http server with prometheus handler
  • Migrate all existing metrics to use github.com/prometheus/client_golang/prometheus metrics
    • All names of metrics have been revised with prometheus naming best practices applied
  • Unblocks the ability to tag metrics with given labels using prometheus.GaugeVec, prometheus.CounterVec, etc

Tests

go test ./...

Run node and ensure all go metrics and gossamer metrics are being outputted via the /metrics endpoint.

Issues

#2220

Primary Reviewer

@timwu20 timwu20 changed the title refactor(metrics): Use default prometheus go collector, and implement standard Prometheus gauges for existing metrics refactor(metrics): use default prometheus go metrics collector, and implement standard Prometheus gauges for existing metrics Jan 20, 2022
@codecov
Copy link

codecov bot commented Jan 20, 2022

Codecov Report

Merging #2219 (3f643c4) into development (be00a69) will decrease coverage by 0.59%.
The diff coverage is 74.77%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #2219      +/-   ##
===============================================
- Coverage        60.41%   59.81%   -0.60%     
===============================================
  Files              210      212       +2     
  Lines            27365    27663     +298     
===============================================
+ Hits             16532    16548      +16     
- Misses            9081     9418     +337     
+ Partials          1752     1697      -55     
Flag Coverage Δ
unit-tests 59.81% <74.77%> (-0.60%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dot/network/config.go 63.01% <ø> (-1.46%) ⬇️
dot/peerset/peerset.go 49.18% <ø> (ø)
dot/sync/chain_sync.go 54.84% <0.00%> (+1.15%) ⬆️
lib/trie/test_utils.go 87.75% <ø> (ø)
dot/network/service.go 56.17% <4.54%> (+1.24%) ⬆️
lib/grandpa/grandpa.go 59.80% <40.00%> (+0.29%) ⬆️
dot/state/block.go 44.92% <62.50%> (+0.91%) ⬆️
internal/metrics/metrics.go 68.88% <68.88%> (ø)
lib/common/common.go 37.33% <71.42%> (+0.32%) ⬆️
lib/trie/trie.go 96.30% <83.63%> (+4.78%) ⬆️
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d946fd...3f643c4. Read the comment docs.

internal/metrics/metrics.go Outdated Show resolved Hide resolved
lib/grandpa/grandpa.go Outdated Show resolved Hide resolved
lib/grandpa/grandpa.go Outdated Show resolved Hide resolved
tests/stress/stress_test.go Show resolved Hide resolved
dot/state/service.go Outdated Show resolved Hide resolved
dot/state/service.go Outdated Show resolved Hide resolved
dot/state/service.go Outdated Show resolved Hide resolved
dot/state/service.go Outdated Show resolved Hide resolved
dot/network/service.go Show resolved Hide resolved
internal/metrics/metrics.go Outdated Show resolved Hide resolved
dot/network/service.go Outdated Show resolved Hide resolved
internal/metrics/metrics.go Outdated Show resolved Hide resolved
lib/grandpa/grandpa.go Outdated Show resolved Hide resolved
@@ -48,7 +50,14 @@ func (s chainSyncState) String() string {
}
}

var pendingBlocksLimit = maxResponseSize * 32
var (
pendingBlocksLimit = maxResponseSize * 32
Copy link
Contributor

Choose a reason for hiding this comment

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

nit a bit out of scope, but I think this could be a constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get an unparam lint error. Apparently there's a function newDisjointBlockSet(limit int) that only gets called with this variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Update your golangci-lint? 🤔

dot/state/service.go Outdated Show resolved Hide resolved
dot/state/block.go Outdated Show resolved Hide resolved
Copy link
Member

@EclesioMeloJunior EclesioMeloJunior left a comment

Choose a reason for hiding this comment

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

just a nit

internal/metrics/metrics.go Outdated Show resolved Hide resolved
Co-authored-by: Eclésio Junior <eclesiomelo.1@gmail.com>
} else {
syncedBlocks.Update(num.Int64())
select {
case <-s.ctx.Done():
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe pass the context as a first argument to that function? Even if it means calling updateMetrics(s.ctx)? That way we can push context 'up' in the call stack and maybe one day not have them as service struct field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have another issue to change the Service interface. With that refactor, I'm going to try and remove the contexts. I'll update this code then.

dot/network/service.go Show resolved Hide resolved
dot/node.go Outdated Show resolved Hide resolved
dot/node.go Outdated Show resolved Hide resolved
dot/state/block.go Outdated Show resolved Hide resolved
internal/metrics/metrics.go Show resolved Hide resolved
internal/metrics/metrics.go Outdated Show resolved Hide resolved
internal/metrics/metrics.go Outdated Show resolved Hide resolved
internal/metrics/metrics.go Outdated Show resolved Hide resolved
timwu20 and others added 6 commits January 26, 2022 23:25
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
@timwu20 timwu20 merged commit e816e31 into development Jan 28, 2022
@timwu20 timwu20 deleted the tim/metrics-refactor branch January 28, 2022 18:51
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