Browse Source

Merge pull request #12106 from jkschneider:simple-enable

* pr/12106:
  Polish "Restore behavior of management.metrics.export.simple.enabled"
  Restore behavior of management.metrics.export.simple.enabled
pull/12066/merge
Stephane Nicoll 8 years ago
parent
commit
fd0293cd5c
  1. 2
      spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.java
  2. 13
      spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleProperties.java
  3. 5
      spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesConfigAdapter.java
  4. 6
      spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  5. 9
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfigurationTests.java
  6. 2
      spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
  7. 16
      spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

2
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.java

@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 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.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -46,6 +47,7 @@ import org.springframework.context.annotation.Configuration;
@ConditionalOnBean(Clock.class) @ConditionalOnBean(Clock.class)
@EnableConfigurationProperties(SimpleProperties.class) @EnableConfigurationProperties(SimpleProperties.class)
@ConditionalOnMissingBean(MeterRegistry.class) @ConditionalOnMissingBean(MeterRegistry.class)
@ConditionalOnProperty(name = "management.metrics.export.simple.enabled", havingValue = "true", matchIfMissing = true)
public class SimpleMetricsExportAutoConfiguration { public class SimpleMetricsExportAutoConfiguration {
@Bean @Bean

13
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleProperties.java

@ -33,11 +33,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "management.metrics.export.simple") @ConfigurationProperties(prefix = "management.metrics.export.simple")
public class SimpleProperties { public class SimpleProperties {
/**
* Enable publishing to the backend.
*/
private boolean enabled;
/** /**
* Step size (i.e. reporting frequency) to use. * Step size (i.e. reporting frequency) to use.
*/ */
@ -48,14 +43,6 @@ public class SimpleProperties {
*/ */
private CountingMode mode = CountingMode.CUMULATIVE; private CountingMode mode = CountingMode.CUMULATIVE;
public boolean getEnabled() {
return this.enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public Duration getStep() { public Duration getStep() {
return this.step; return this.step;
} }

5
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesConfigAdapter.java

@ -41,11 +41,6 @@ public class SimplePropertiesConfigAdapter
return null; return null;
} }
@Override
public boolean enabled() {
return get(SimpleProperties::getEnabled, SimpleConfig.super::enabled);
}
@Override @Override
public Duration step() { public Duration step() {
return get(SimpleProperties::getStep, SimpleConfig.super::step); return get(SimpleProperties::getStep, SimpleConfig.super::step);

6
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@ -215,6 +215,12 @@
"description": "Whether to enable uptime metrics.", "description": "Whether to enable uptime metrics.",
"defaultValue": true "defaultValue": true
}, },
{
"name": "management.metrics.export.simple.enabled",
"type": "java.lang.Boolean",
"description": "Whether, in the absence of any other exporter, exporting of metrics to an in-memory backend is enabled.",
"defaultValue": true
},
{ {
"name": "management.trace.http.enabled", "name": "management.trace.http.enabled",
"type": "java.lang.Boolean", "type": "java.lang.Boolean",

9
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfigurationTests.java

@ -51,6 +51,15 @@ public class SimpleMetricsExportAutoConfigurationTests {
.hasSingleBean(Clock.class).hasSingleBean(SimpleConfig.class)); .hasSingleBean(Clock.class).hasSingleBean(SimpleConfig.class));
} }
@Test
public void backsOffWhenSpecificallyDisabled() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.simple.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(SimpleMeterRegistry.class)
.doesNotHaveBean(SimpleConfig.class));
}
@Test @Test
public void allowsConfigToBeCustomized() { public void allowsConfigToBeCustomized() {
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class) this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)

2
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

@ -1384,7 +1384,7 @@ content into your application. Rather, pick only the properties that you need.
management.metrics.export.signalfx.uri= # Optional custom URI for the SignalFX API. management.metrics.export.signalfx.uri= # Optional custom URI for the SignalFX API.
management.metrics.export.simple.mode=cumulative # Counting mode. management.metrics.export.simple.mode=cumulative # Counting mode.
management.metrics.export.simple.step=10s # Step size (i.e. reporting frequency) to use. management.metrics.export.simple.step=10s # Step size (i.e. reporting frequency) to use.
management.metrics.export.statsd.enabled= # Whether exporting of metrics to this backend is enabled. management.metrics.export.statsd.enabled=true # Whether, in the absence of any other exporter, exporting of metrics to an in-memory backend is enabled.
management.metrics.export.statsd.flavor=datadog # StatsD line protocol to use. management.metrics.export.statsd.flavor=datadog # StatsD line protocol to use.
management.metrics.export.statsd.host=localhost # Host of the StatsD server to receive exported metrics. management.metrics.export.statsd.host=localhost # Host of the StatsD server to receive exported metrics.
management.metrics.export.statsd.max-packet-length=1400 # Total length of a single payload should be kept within your network's MTU. management.metrics.export.statsd.max-packet-length=1400 # Total length of a single payload should be kept within your network's MTU.

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

@ -1272,6 +1272,22 @@ using:
[[production-ready-metrics-export-simple]]
==== Simple
Micrometer ships with a simple, in-memory backend that is automatically used as a fallback
if no other registry is configured. This allows you to see what metrics are collected in
the <<production-ready-metrics-endpoint,metrics endpoint>>.
The in-memory backend disables itself as soon as you're using any of the other available
backend. You can also disable it explicitly:
[source,properties,indent=0]
----
management.metrics.export.simple.enabled=false
----
[[production-ready-metrics-export-newrelic]] [[production-ready-metrics-export-newrelic]]
==== New Relic ==== New Relic
New Relic registry pushes metrics to New Relic periodically. To export metrics to New Relic registry pushes metrics to New Relic periodically. To export metrics to

Loading…
Cancel
Save