Fix conditions that lead to auto-configure PushGateway

See gh-22919
This commit is contained in:
smlc 2020-08-12 13:42:46 +01:00 committed by Stephane Nicoll
parent 4f65f2e9f1
commit c355b95f6c
2 changed files with 7 additions and 2 deletions

View File

@ -154,6 +154,12 @@ class PrometheusMetricsExportAutoConfigurationTests {
.run((context) -> hasGatewayURL(context, "https://example.com:8080/metrics/"));
}
@Test
void pushGatewayIsNotConfiguredWhenEnabledFlagIsNotSet() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean(PrometheusPushGatewayManager.class));
}
private void hasGatewayURL(AssertableApplicationContext context, String url) {
assertThat(context).hasSingleBean(PrometheusPushGatewayManager.class);
PrometheusPushGatewayManager gatewayManager = context.getBean(PrometheusPushGatewayManager.class);

View File

@ -1552,13 +1552,12 @@ To enable Prometheus Pushgateway support, add the following dependency to your p
</dependency>
----
When the Prometheus Pushgateway dependency is present on the classpath, Spring Boot auto-configures a `PrometheusPushGatewayManager` bean.
When the Prometheus Pushgateway dependency is present on the classpath and the `configprop:management.metrics.export.prometheus.pushgateway.enabled` property is set to true, a PrometheusPushGatewayManager bean is auto-configured.
This manages the pushing of metrics to a Prometheus Pushgateway.
The `PrometheusPushGatewayManager` can be tuned using properties under `management.metrics.export.prometheus.pushgateway`.
For advanced configuration, you can also provide your own `PrometheusPushGatewayManager` bean.
[[production-ready-metrics-export-signalfx]]
==== SignalFx
SignalFx registry pushes metrics to {micrometer-registry-docs}/signalFx[SignalFx] periodically.