-
Notifications
You must be signed in to change notification settings - Fork 622
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 prometheus metrics #335
Conversation
remove all calls to metrics.Counter and instead inline using the prometheus/promauto package
that's used to give more control and therefore create unique registers per tests avoiding the "duplicate metrics collector registration attempted" panic message see prometheus/client_golang#716 (comment)
Codecov Report
@@ Coverage Diff @@
## main #335 +/- ##
==========================================
- Coverage 53.99% 53.96% -0.03%
==========================================
Files 102 102
Lines 4775 4967 +192
==========================================
+ Hits 2578 2680 +102
- Misses 1958 2048 +90
Partials 239 239
Continue to review full report at Codecov.
|
@eh-am This all looks great, thank you!
Generally we try to avoid global state anyway, so this is great
This is fine, I think it's actually better if they're eagerly initiated like that. |
couple things: 1 - semantics have changed, ie the metrics are initialized to 0 even if we can't ever generate metrics data so think in a dashboard a 0 value vs simply nothing showing up 2 - some of the metrics generated were dynamic, for example, based on files in a directory that has been hardcoded
Hey, with the newest updates the metrics package is gone. I've created a docker-compose in I think all this can be deleted, but I left it in the PR so that anybody can run and validate the refactored metrics are working as they should. Apart from that, there are a few points worth mentioning:
Another example is the type conversion, which was previously centralized, which kinda suggested to pass
As a bonus, here's the output of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great, I will merge
Use a volume to hold fire's data
This is prework for #332
PR is not ready, it's just to get some feedback early on
Started getting rid of the metrics package, so far only moved out the Counters and started moving out the Gauge stuff
Tests were breaking with variations of
So ended up taking the registry as a dependency, as per
prometheus/client_golang#716 (comment) 's suggestion
which in consequence required updating the constructor in multiple places
I will double check all this work later, since this is not something very testable (I pondered with the idea of somehow hitting /metrics and parsing the output but meh)
Here's a diff for reference. One clear difference is that lazy instanciated metrics (such as
evictions_count
are now eagerly initiated with 0)