Polish “Auto-configure FileDescriptorMetrics”

Closes gh-12022
pull/11909/merge
Andy Wilkinson 7 years ago
parent a51fcd071e
commit 25520a9e32

@ -128,7 +128,7 @@ public class MetricsAutoConfiguration {
} }
@Bean @Bean
@ConditionalOnProperty(name = "management.metrics.binders.fds.enabled", matchIfMissing = true) @ConditionalOnProperty(name = "management.metrics.binders.files.enabled", matchIfMissing = true)
@ConditionalOnMissingBean @ConditionalOnMissingBean
public FileDescriptorMetrics fileDescriptorMetrics() { public FileDescriptorMetrics fileDescriptorMetrics() {
return new FileDescriptorMetrics(); return new FileDescriptorMetrics();

@ -179,6 +179,12 @@
"name": "management.info.git.mode", "name": "management.info.git.mode",
"defaultValue": "simple" "defaultValue": "simple"
}, },
{
"name": "management.metrics.binders.files.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable files metrics.",
"defaultValue": true
},
{ {
"name": "management.metrics.binders.integration.enabled", "name": "management.metrics.binders.integration.enabled",
"type": "java.lang.Boolean", "type": "java.lang.Boolean",

@ -213,20 +213,19 @@ public class MetricsAutoConfigurationTests {
@Test @Test
public void autoConfiguresFileDescriptorMetrics() { public void autoConfiguresFileDescriptorMetrics() {
this.runner.run( this.runner.run((context) -> assertThat(context)
(context) -> assertThat(context)
.hasSingleBean(FileDescriptorMetrics.class)); .hasSingleBean(FileDescriptorMetrics.class));
} }
@Test @Test
public void allowsFileDescriptorMetricsToBeDisabled() { public void allowsFileDescriptorMetricsToBeDisabled() {
this.runner.withPropertyValues("management.metrics.binders.fds.enabled=false") this.runner.withPropertyValues("management.metrics.binders.files.enabled=false")
.run((context) -> assertThat(context) .run((context) -> assertThat(context)
.doesNotHaveBean(FileDescriptorMetrics.class)); .doesNotHaveBean(FileDescriptorMetrics.class));
} }
@Test @Test
public void allowsCustomFileDescriptorToBeUsed() { public void allowsCustomFileDescriptorMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomFileDescriptorMetricsConfiguration.class) this.runner.withUserConfiguration(CustomFileDescriptorMetricsConfiguration.class)
.run((context) -> assertThat(context) .run((context) -> assertThat(context)
.hasSingleBean(FileDescriptorMetrics.class) .hasSingleBean(FileDescriptorMetrics.class)

@ -1295,6 +1295,7 @@ content into your application. Rather, pick only the properties that you need.
management.info.git.mode=simple # Mode to use to expose git information. management.info.git.mode=simple # Mode to use to expose git information.
# METRICS # METRICS
management.metrics.binders.files.enabled=true # Whether to enable files metrics.
management.metrics.binders.integration.enabled=true # Whether to enable Spring Integration metrics. management.metrics.binders.integration.enabled=true # Whether to enable Spring Integration metrics.
management.metrics.binders.jvm.enabled=true # Whether to enable JVM metrics. management.metrics.binders.jvm.enabled=true # Whether to enable JVM metrics.
management.metrics.binders.logback.enabled=true # Whether to enable Logback metrics. management.metrics.binders.logback.enabled=true # Whether to enable Logback metrics.

Loading…
Cancel
Save