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 7 years ago
commit fd0293cd5c

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

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

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

@ -215,6 +215,12 @@
"description": "Whether to enable uptime metrics.",
"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",
"type": "java.lang.Boolean",

@ -51,6 +51,15 @@ public class SimpleMetricsExportAutoConfigurationTests {
.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
public void allowsConfigToBeCustomized() {
this.contextRunner.withUserConfiguration(CustomConfigConfiguration.class)

@ -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.simple.mode=cumulative # Counting mode.
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.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.

@ -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]]
==== New Relic
New Relic registry pushes metrics to New Relic periodically. To export metrics to

Loading…
Cancel
Save