metrics: handle values from config file #565
Merged
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
--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 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