-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Add auto-config for Prometheus Pushgateway. Fixes #14346 #14353
Conversation
1275007
to
94430f8
Compare
36ef68b
to
6adf90a
Compare
6adf90a
to
f4f1a00
Compare
…jects#14346 Signed-off-by: David J. M. Karlsen <david@davidkarlsen.com>
f4f1a00
to
ae2e467
Compare
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.
Thanks very much for the PR. I've added a few suggestions.
...ctuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...ctuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...ctuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...ctuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...ctuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.java
Outdated
Show resolved
Hide resolved
@@ -128,6 +129,18 @@ public void allowsCustomScrapeEndpointToBeUsed() { | |||
.hasSingleBean(PrometheusScrapeEndpoint.class)); | |||
} | |||
|
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 would be nice if we could test more of the logic in PushGatewayHandler
somehow. There's logic in the push
and shutdown
methods that we don't really have covered. I'm not totally sure how we can do that, perhaps splitting the class so the logic is separate from the scheduling and then testing the logic part with mocks?
Don't worry too much about that if you can't find a way to do it, we can look to it when we merge.
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.
Fixed all comments except this one
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.
No worries. Thanks for your efforts, we'll try to find a way to add some additional tests when we merge it.
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.
Great - I hope it will go into 2.1.0?
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.
@philwebb WDYT?
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.
ah - I see the added milestones now!
e98235c
to
d178fbb
Compare
Rework Prometheus push gateway support so that the central class can be used outside of auto-configuration. The shutdown flags have also been replaced with a single "shutdown-operation" property since it's unlikely that both "push" and "delete" will be required. It's also possible now to supply a `TaskScheduler` to the manager. See gh-14353
* pr/14353: Polish "Add Prometheus push gateway support" Add Prometheus push gateway support
@davidkarlsen Thanks very much for contributing this. I've merged it into 2.1 with some additional changes. I'm not that familiar with the Pushgateway, so if anything looks wrong please let me know. One specific change I want to point out is replacing the boolean flags with a Thanks again! |
@philwebb Thanks a lot for merging! It looks good. If it would make sense to do push and then delete depends on how this is implemented in pushgateway. All I know is that the delete is async and does not happen immediately: https://www.robustperception.io/common-pitfalls-when-using-the-pushgateway - if it is implemented so that it would allow for a last scrape to happen, THEN delete - it would make sense. If that would ever be the case then PUSH_AND_DELETE could be added to handle that. It would nevertheless be a corner-case - let's leave it easy and clean for now. Thanks again for your effort - appreciated! |
Is there an example of how to use this functionality? |
@danielsuter I don't think we every updated the docs. I've raised #16853. |
Fixes #14346 - adds support for Prometheus Pushgateway.
Basically a backport of master of https://github.com/micrometer-metrics/micrometer/blob/master/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/prometheus/PrometheusMetricsExportAutoConfiguration.java
Take note of the added dependency on the pushgateway library, care needs to be taken to make it harmonize with the transitive dependencies on other Prometheus libraries through io.micrometer:micrometer-registry-prometheus .
@snicoll
Can you take a quick look and give me feedback on anything that needs fixing?
This change is