metrics: handle values from config file#565
Merged
Merged
Conversation
Raneet10
approved these changes
Oct 20, 2022
Codecov ReportBase: 56.83% // Head: 56.86% // Increases project coverage by
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
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. |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The metrics package uses global variables to enable metrics collection (with the flag
--metricsand--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 toinit()(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
Checklist
Testing