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
@ConditionalOnProperty(name = "management.metrics.binders.fds.enabled", matchIfMissing = true)
@ConditionalOnProperty(name = "management.metrics.binders.files.enabled", matchIfMissing = true)
@ConditionalOnMissingBean
public FileDescriptorMetrics fileDescriptorMetrics() {
return new FileDescriptorMetrics();

@ -179,7 +179,13 @@
"name": "management.info.git.mode",
"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",
"type": "java.lang.Boolean",
"description": "Whether to enable Spring Integration metrics.",

@ -213,20 +213,19 @@ public class MetricsAutoConfigurationTests {
@Test
public void autoConfiguresFileDescriptorMetrics() {
this.runner.run(
(context) -> assertThat(context)
.hasSingleBean(FileDescriptorMetrics.class));
this.runner.run((context) -> assertThat(context)
.hasSingleBean(FileDescriptorMetrics.class));
}
@Test
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)
.doesNotHaveBean(FileDescriptorMetrics.class));
}
@Test
public void allowsCustomFileDescriptorToBeUsed() {
public void allowsCustomFileDescriptorMetricsToBeUsed() {
this.runner.withUserConfiguration(CustomFileDescriptorMetricsConfiguration.class)
.run((context) -> assertThat(context)
.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.
# 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.jvm.enabled=true # Whether to enable JVM metrics.
management.metrics.binders.logback.enabled=true # Whether to enable Logback metrics.

Loading…
Cancel
Save