Commit 3942ba2e authored by Andy Wilkinson's avatar Andy Wilkinson

Consistently use the spring.metrics configuration property prefix

See gh-9970
parent 5efcbad7
...@@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import; ...@@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import;
public class AtlasExportConfiguration { public class AtlasExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.atlas.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.atlas.enabled", matchIfMissing = true)
public MetricsExporter atlasExporter(AtlasConfig config, Clock clock) { public MetricsExporter atlasExporter(AtlasConfig config, Clock clock) {
return () -> new AtlasMeterRegistry(config, clock); return () -> new AtlasMeterRegistry(config, clock);
} }
......
...@@ -29,12 +29,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -29,12 +29,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @since 2.0.0 * @since 2.0.0
* @author Jon Schneider * @author Jon Schneider
*/ */
@ConfigurationProperties(prefix = "metrics.atlas") @ConfigurationProperties(prefix = "spring.metrics.atlas")
public class AtlasProperties extends RegistryProperties implements AtlasConfig { public class AtlasProperties extends RegistryProperties implements AtlasConfig {
@Override @Override
protected String prefix() { protected String prefix() {
return "atlas"; return "spring.metrics.atlas";
} }
public void setStep(Duration step) { public void setStep(Duration step) {
......
...@@ -43,7 +43,7 @@ import org.springframework.context.annotation.Import; ...@@ -43,7 +43,7 @@ import org.springframework.context.annotation.Import;
public class DatadogExportConfiguration { public class DatadogExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.datadog.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.datadog.enabled", matchIfMissing = true)
public MetricsExporter datadogExporter(DatadogConfig config, Clock clock) { public MetricsExporter datadogExporter(DatadogConfig config, Clock clock) {
return () -> new DatadogMeterRegistry(config, clock); return () -> new DatadogMeterRegistry(config, clock);
} }
......
...@@ -27,12 +27,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -27,12 +27,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Jon Schneider * @author Jon Schneider
* @since 2.0.0 * @since 2.0.0
*/ */
@ConfigurationProperties(prefix = "metrics.datadog") @ConfigurationProperties(prefix = "spring.metrics.datadog")
public class DatadogProperties extends StepRegistryProperties implements DatadogConfig { public class DatadogProperties extends StepRegistryProperties implements DatadogConfig {
@Override @Override
public String prefix() { public String prefix() {
return "metrics.datadog"; return "spring.metrics.datadog";
} }
public DatadogProperties() { public DatadogProperties() {
......
...@@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import; ...@@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import;
public class GangliaExportConfiguration { public class GangliaExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.ganglia.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.ganglia.enabled", matchIfMissing = true)
public MetricsExporter gangliaExporter(GangliaConfig config, public MetricsExporter gangliaExporter(GangliaConfig config,
HierarchicalNameMapper nameMapper, Clock clock) { HierarchicalNameMapper nameMapper, Clock clock) {
return () -> new GangliaMeterRegistry(config, nameMapper, clock); return () -> new GangliaMeterRegistry(config, nameMapper, clock);
......
...@@ -31,12 +31,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -31,12 +31,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Jon Schneider * @author Jon Schneider
* @since 2.0.0 * @since 2.0.0
*/ */
@ConfigurationProperties(prefix = "metrics.ganglia") @ConfigurationProperties(prefix = "spring.metrics.ganglia")
public class GangliaProperties extends RegistryProperties implements GangliaConfig { public class GangliaProperties extends RegistryProperties implements GangliaConfig {
@Override @Override
public String prefix() { public String prefix() {
return "metrics.ganglia"; return "spring.metrics.ganglia";
} }
public void setStep(Duration step) { public void setStep(Duration step) {
......
...@@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import; ...@@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import;
public class GraphiteExportConfiguration { public class GraphiteExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.graphite.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.graphite.enabled", matchIfMissing = true)
public MetricsExporter graphiteExporter(GraphiteConfig config, public MetricsExporter graphiteExporter(GraphiteConfig config,
HierarchicalNameMapper nameMapper, Clock clock) { HierarchicalNameMapper nameMapper, Clock clock) {
return () -> new GraphiteMeterRegistry(config, nameMapper, clock); return () -> new GraphiteMeterRegistry(config, nameMapper, clock);
......
...@@ -30,12 +30,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -30,12 +30,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Jon Schneider * @author Jon Schneider
* @since 2.0.0 * @since 2.0.0
*/ */
@ConfigurationProperties(prefix = "metrics.graphite") @ConfigurationProperties(prefix = "spring.metrics.graphite")
public class GraphiteProperties extends RegistryProperties implements GraphiteConfig { public class GraphiteProperties extends RegistryProperties implements GraphiteConfig {
@Override @Override
public String prefix() { public String prefix() {
return "metrics.graphite"; return "spring.metrics.graphite";
} }
public void setStep(Duration step) { public void setStep(Duration step) {
......
...@@ -43,7 +43,7 @@ import org.springframework.context.annotation.Import; ...@@ -43,7 +43,7 @@ import org.springframework.context.annotation.Import;
public class InfluxExportConfiguration { public class InfluxExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.influx.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.influx.enabled", matchIfMissing = true)
public MetricsExporter influxExporter(InfluxConfig config, Clock clock) { public MetricsExporter influxExporter(InfluxConfig config, Clock clock) {
return () -> new InfluxMeterRegistry(config, clock); return () -> new InfluxMeterRegistry(config, clock);
} }
......
...@@ -28,12 +28,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -28,12 +28,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Jon Schneider * @author Jon Schneider
* @since 2.0.0 * @since 2.0.0
*/ */
@ConfigurationProperties(prefix = "metrics.influx") @ConfigurationProperties(prefix = "spring.metrics.influx")
public class InfluxProperties extends StepRegistryProperties implements InfluxConfig { public class InfluxProperties extends StepRegistryProperties implements InfluxConfig {
@Override @Override
public String prefix() { public String prefix() {
return "metrics.influx"; return "spring.metrics.influx";
} }
public void setDb(String db) { public void setDb(String db) {
......
...@@ -38,7 +38,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -38,7 +38,7 @@ import org.springframework.context.annotation.Configuration;
public class JmxExportConfiguration { public class JmxExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.jmx.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.jmx.enabled", matchIfMissing = true)
public MetricsExporter jmxExporter(HierarchicalNameMapper nameMapper, Clock clock) { public MetricsExporter jmxExporter(HierarchicalNameMapper nameMapper, Clock clock) {
return () -> new JmxMeterRegistry(nameMapper, clock); return () -> new JmxMeterRegistry(nameMapper, clock);
} }
......
...@@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
public class PrometheusExportConfiguration { public class PrometheusExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.prometheus.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.prometheus.enabled", matchIfMissing = true)
public MetricsExporter prometheusExporter(PrometheusConfig config, public MetricsExporter prometheusExporter(PrometheusConfig config,
CollectorRegistry collectorRegistry, Clock clock) { CollectorRegistry collectorRegistry, Clock clock) {
return () -> new PrometheusMeterRegistry(config, collectorRegistry, clock); return () -> new PrometheusMeterRegistry(config, collectorRegistry, clock);
......
...@@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Jon Schneider * @author Jon Schneider
* @since 2.0.0 * @since 2.0.0
*/ */
@ConfigurationProperties(prefix = "metrics.prometheus") @ConfigurationProperties(prefix = "spring.metrics.prometheus")
public class PrometheusProperties extends RegistryProperties implements PrometheusConfig { public class PrometheusProperties extends RegistryProperties implements PrometheusConfig {
private boolean enabled = true; private boolean enabled = true;
...@@ -46,7 +46,7 @@ public class PrometheusProperties extends RegistryProperties implements Promethe ...@@ -46,7 +46,7 @@ public class PrometheusProperties extends RegistryProperties implements Promethe
@Override @Override
public String prefix() { public String prefix() {
return "metrics.prometheus"; return "spring.metrics.prometheus";
} }
} }
...@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration;
public class SimpleExportConfiguration { public class SimpleExportConfiguration {
@Bean @Bean
@ConditionalOnProperty(value = "metrics.simple.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.metrics.simple.enabled", matchIfMissing = true)
@ConditionalOnMissingBean(MetricsExporter.class) @ConditionalOnMissingBean(MetricsExporter.class)
public MetricsExporter simpleExporter(Clock clock) { public MetricsExporter simpleExporter(Clock clock) {
return () -> new SimpleMeterRegistry(clock); return () -> new SimpleMeterRegistry(clock);
......
...@@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Jon Schneider * @author Jon Schneider
* @since 2.0.0 * @since 2.0.0
*/ */
@ConfigurationProperties(prefix = "metrics.simple") @ConfigurationProperties(prefix = "spring.metrics.simple")
public class SimpleProperties { public class SimpleProperties {
private boolean enabled = true; private boolean enabled = true;
......
...@@ -39,10 +39,13 @@ public class SimpleExportConfigurationTests { ...@@ -39,10 +39,13 @@ public class SimpleExportConfigurationTests {
@Test @Test
public void simpleMeterRegistryIsInTheCompositeWhenNoOtherRegistryIs() { public void simpleMeterRegistryIsInTheCompositeWhenNoOtherRegistryIs() {
new ApplicationContextRunner() new ApplicationContextRunner()
.withPropertyValues("metrics.atlas.enabled=false", .withPropertyValues("spring.metrics.atlas.enabled=false",
"metrics.datadog.enabled=false", "metrics.ganglia.enabled=false", "spring.metrics.datadog.enabled=false",
"metrics.graphite.enabled=false", "metrics.influx.enabled=false", "spring.metrics.ganglia.enabled=false",
"metrics.jmx.enabled=false", "metrics.prometheus.enabled=false") "spring.metrics.graphite.enabled=false",
"spring.metrics.influx.enabled=false",
"spring.metrics.jmx.enabled=false",
"spring.metrics.prometheus.enabled=false")
.withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class))
.run((context) -> { .run((context) -> {
CompositeMeterRegistry meterRegistry = context CompositeMeterRegistry meterRegistry = context
......
...@@ -1267,7 +1267,14 @@ content into your application; rather pick only the properties that you need. ...@@ -1267,7 +1267,14 @@ content into your application; rather pick only the properties that you need.
management.trace.include=request-headers,response-headers,cookies,errors # Items to be included in the trace. management.trace.include=request-headers,response-headers,cookies,errors # Items to be included in the trace.
# METRICS # METRICS
spring.metrics.use-global-registry=true # Whether or not auto-configured MeterRegistry implementations should be bound to the global static registry on Metrics spring.metrics.atlas.enabled=true # Whether not exporting of metrics to Atlas is enabled.
spring.metrics.ganglia.enabled=true # Whether not exporting of metrics to Ganglia is enabled.
spring.metrics.graphite.enabled=true # Whether not exporting of metrics to Graphite is enabled.
spring.metrics.influx.enabled=true # Whether not exporting of metrics to InfluxDB is enabled.
spring.metrics.jmx.enabled=true # Whether not exporting of metrics to JMX is enabled.
spring.metrics.prometheus.enabled=true # Whether not exporting of metrics to Prometheus is enabled.
spring.metrics.simple.enabled=true # Whether not exporting of metrics to a simple in-memory store is enabled.
spring.metrics.use-global-registry=true # Whether or not auto-configured MeterRegistry implementations should be bound to the global static registry on Metrics
spring.metrics.web.client.record-request-percentiles=false # Whether or not instrumented requests record percentiles histogram buckets by default. spring.metrics.web.client.record-request-percentiles=false # Whether or not instrumented requests record percentiles histogram buckets by default.
spring.metrics.web.client.requests-metric-name=http.client.requests # Name of the metric for sent requests. spring.metrics.web.client.requests-metric-name=http.client.requests # Name of the metric for sent requests.
spring.metrics.web.server.auto-time-requests=true Whether or not requests handled by Spring MVC or WebFlux should be automatically timed. spring.metrics.web.server.auto-time-requests=true Whether or not requests handled by Spring MVC or WebFlux should be automatically timed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment