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

metrics: handle values from config file #565

Merged
merged 3 commits into from
Oct 20, 2022
Merged

Conversation

manav2401
Copy link
Contributor

@manav2401 manav2401 commented Oct 20, 2022

Description

The metrics package uses global variables to enable metrics collection (with the flag --metrics and --metrics.expensive). As we're moving towards a toml config based approach, we found out that the values of these 2 parameters from toml file weren't being honoured in some cases. On further investigation we found out that due to the call to init() (in metrics/metrics.go), OS arguments were being read and metrics were being set based on those arguments.

Now, there are some metrics which needs to be registered as soon the bor process starts. We were setting these global values but at much later point in the code when we're done setting up the node related processes which caused all the metric (meters, counters, gauges, etc) registrations to fail and hence leading to 0 values in prometheus. If we were to start bor using cli, it would work as it finds the flags in OS args but not in case of toml.

This PR fixes this by reading the config file itself in the init() function of metrics package and enabling/disabling the global variables before any other process starts.

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply

Testing

  • I have tested this code manually on local environment
  • I have tested this code manually on mumbai/mainnet

@manav2401 manav2401 requested a review from a team October 20, 2022 19:13
Copy link
Contributor

@cffls cffls left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@codecov-commenter
Copy link

Codecov Report

Base: 56.83% // Head: 56.86% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (4131b3c) compared to base (aab7214).
Patch coverage: 30.43% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #565      +/-   ##
===========================================
+ Coverage    56.83%   56.86%   +0.02%     
===========================================
  Files          606      606              
  Lines        70128    70149      +21     
===========================================
+ Hits         39860    39890      +30     
- Misses       26845    26852       +7     
+ Partials      3423     3407      -16     
Impacted Files Coverage Δ
internal/cli/server/server.go 30.21% <0.00%> (-0.68%) ⬇️
metrics/metrics.go 10.95% <36.84%> (+9.17%) ⬆️
p2p/discover/v4_udp.go 72.75% <0.00%> (-4.35%) ⬇️
les/pruner.go 60.71% <0.00%> (-3.58%) ⬇️
les/distributor.go 79.68% <0.00%> (-2.35%) ⬇️
consensus/ethash/ethash.go 51.90% <0.00%> (-2.30%) ⬇️
p2p/discover/table.go 82.48% <0.00%> (-1.83%) ⬇️
core/rawdb/chain_iterator.go 58.38% <0.00%> (-1.25%) ⬇️
rpc/client.go 82.55% <0.00%> (-1.17%) ⬇️
les/costtracker.go 62.43% <0.00%> (-0.53%) ⬇️
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@manav2401 manav2401 merged commit 8aab374 into develop Oct 20, 2022
@manav2401 manav2401 deleted the manav/pos-930-fix-metrics branch October 20, 2022 20:45
cffls pushed a commit to cffls/bor that referenced this pull request Oct 20, 2022
* metrics: handle metrics flag from config in metrics.init()

* internal/cli/server: log for metrics enabling and misconfiguration
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