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 Reviewable

Comment From: philwebb

@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 shutdown-operation property. I assume that a user would never want to do both a push and a delete on shutdown. If this assumption is wrong, let me know.

Thanks again!

Comment From: davidkarlsen

@philwebb Thanks a lot for merging! It looks good. Some background on why there is a delete at all: https://prometheus.io/docs/practices/pushing/ (bullet no. 3).

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!

Comment From: danielsuter

Is there an example of how to use this functionality?

Comment From: philwebb

@danielsuter I don't think we every updated the docs. I've raised #16853.