Skip to content

Commit c355b95

Browse files
smlcsnicoll
authored andcommitted
Fix conditions that lead to auto-configure PushGateway
See gh-22919
1 parent 4f65f2e commit c355b95

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfigurationTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ void withCustomPushGatewayURL() {
154154
.run((context) -> hasGatewayURL(context, "https://example.com:8080/metrics/"));
155155
}
156156

157+
@Test
158+
void pushGatewayIsNotConfiguredWhenEnabledFlagIsNotSet() {
159+
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
160+
.run((context) -> assertThat(context).doesNotHaveBean(PrometheusPushGatewayManager.class));
161+
}
162+
157163
private void hasGatewayURL(AssertableApplicationContext context, String url) {
158164
assertThat(context).hasSingleBean(PrometheusPushGatewayManager.class);
159165
PrometheusPushGatewayManager gatewayManager = context.getBean(PrometheusPushGatewayManager.class);

spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,13 +1552,12 @@ To enable Prometheus Pushgateway support, add the following dependency to your p
15521552
</dependency>
15531553
----
15541554

1555-
When the Prometheus Pushgateway dependency is present on the classpath, Spring Boot auto-configures a `PrometheusPushGatewayManager` bean.
1555+
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.
15561556
This manages the pushing of metrics to a Prometheus Pushgateway.
15571557
The `PrometheusPushGatewayManager` can be tuned using properties under `management.metrics.export.prometheus.pushgateway`.
15581558
For advanced configuration, you can also provide your own `PrometheusPushGatewayManager` bean.
15591559

15601560

1561-
15621561
[[production-ready-metrics-export-signalfx]]
15631562
==== SignalFx
15641563
SignalFx registry pushes metrics to {micrometer-registry-docs}/signalFx[SignalFx] periodically.

0 commit comments

Comments
 (0)