mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Polish PrometheusPushGatewayConfiguration
See gh-44069 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
This commit is contained in:
committed by
Phillip Webb
parent
2b72e1170a
commit
1749235dbd
+2
-2
@@ -37,9 +37,9 @@ import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusScra
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -102,7 +102,7 @@ public class PrometheusMetricsExportAutoConfiguration {
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(PushGateway.class)
|
||||
@ConditionalOnProperty(prefix = "management.prometheus.metrics.export.pushgateway", name = "enabled")
|
||||
@ConditionalOnBooleanProperty("management.prometheus.metrics.export.pushgateway.enabled")
|
||||
static class PrometheusPushGatewayConfiguration {
|
||||
|
||||
/**
|
||||
|
||||
+8
@@ -186,6 +186,14 @@ class PrometheusMetricsExportAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void withPushGatewayDisabled() {
|
||||
this.contextRunner.withConfiguration(AutoConfigurations.of(ManagementContextAutoConfiguration.class))
|
||||
.withPropertyValues("management.prometheus.metrics.export.pushgateway.enabled=false")
|
||||
.withUserConfiguration(BaseConfiguration.class)
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(PrometheusPushGatewayManager.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void withPushGatewayNoBasicAuth() {
|
||||
this.contextRunner.withConfiguration(AutoConfigurations.of(ManagementContextAutoConfiguration.class))
|
||||
|
||||
Reference in New Issue
Block a user