-
Notifications
You must be signed in to change notification settings - Fork 421
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
Change how reporters subscribe to metrics #3148
base: master
Are you sure you want to change the base?
Conversation
Now every call to ensure_metric/3 also subscribes all reporters to it. This makes init_subscriptions/0 redundant. The benefit is that some metrics started after the call to mongoose_metrics:init were not reported and now such situation is impossible.
Codecov Report
@@ Coverage Diff @@
## master #3148 +/- ##
==========================================
- Coverage 79.52% 79.48% -0.04%
==========================================
Files 397 397
Lines 32320 32310 -10
==========================================
- Hits 25701 25681 -20
- Misses 6619 6629 +10
Continue to review full report at Codecov.
|
subscribe_metric(Name, Type) -> | ||
Reporters = exometer_report:list_reporters(), | ||
lists:foreach( | ||
fun({ReporterName, _ReporterPid}) -> |
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.
good catch to match Reporter here properly.
Reporting a bad result from exometer_report:subscribe would help to avoid this small bug...
exometer_report:subscribe(Reporter, Name, default, Interval). | ||
|
||
subscribe_to_all(Reporter, Interval) -> |
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.
there are two reasons it's done as is:
- it could be a bit faster to subscribe to all at once (need to test that)
- metrics are reported with different initial offset interval if not subscribed at once.
Now every call to
ensure_metric/3
also subscribes all reporters to it, which I think is a less surprising API. This makesinit_subscriptions/0
redundant. The benefit is that some metrics started after the call to mongoose_metrics:init were not reported (global.unregister_command
), thus not visible in Graphite for example, and now such situation is impossible.This PR is just a proposition to solve the problem. The upside is that if you ensure a metric exists, it is also reported (if any reporters are set). The downside is that there is less flexibility in adding reporters, or for example using some reporters for some metrics, and not subscribing them to others.