Consistently use the spring.metrics configuration property prefix
See gh-9970
This commit is contained in:
parent
5efcbad751
commit
3942ba2e68
|
|
@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import;
|
|||
public class AtlasExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.atlas.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.atlas.enabled", matchIfMissing = true)
|
||||
public MetricsExporter atlasExporter(AtlasConfig config, Clock clock) {
|
||||
return () -> new AtlasMeterRegistry(config, clock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @since 2.0.0
|
||||
* @author Jon Schneider
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "metrics.atlas")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.atlas")
|
||||
public class AtlasProperties extends RegistryProperties implements AtlasConfig {
|
||||
|
||||
@Override
|
||||
protected String prefix() {
|
||||
return "atlas";
|
||||
return "spring.metrics.atlas";
|
||||
}
|
||||
|
||||
public void setStep(Duration step) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Import;
|
|||
public class DatadogExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.datadog.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.datadog.enabled", matchIfMissing = true)
|
||||
public MetricsExporter datadogExporter(DatadogConfig config, Clock clock) {
|
||||
return () -> new DatadogMeterRegistry(config, clock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "metrics.datadog")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.datadog")
|
||||
public class DatadogProperties extends StepRegistryProperties implements DatadogConfig {
|
||||
|
||||
@Override
|
||||
public String prefix() {
|
||||
return "metrics.datadog";
|
||||
return "spring.metrics.datadog";
|
||||
}
|
||||
|
||||
public DatadogProperties() {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import;
|
|||
public class GangliaExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.ganglia.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.ganglia.enabled", matchIfMissing = true)
|
||||
public MetricsExporter gangliaExporter(GangliaConfig config,
|
||||
HierarchicalNameMapper nameMapper, Clock clock) {
|
||||
return () -> new GangliaMeterRegistry(config, nameMapper, clock);
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "metrics.ganglia")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.ganglia")
|
||||
public class GangliaProperties extends RegistryProperties implements GangliaConfig {
|
||||
|
||||
@Override
|
||||
public String prefix() {
|
||||
return "metrics.ganglia";
|
||||
return "spring.metrics.ganglia";
|
||||
}
|
||||
|
||||
public void setStep(Duration step) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import org.springframework.context.annotation.Import;
|
|||
public class GraphiteExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.graphite.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.graphite.enabled", matchIfMissing = true)
|
||||
public MetricsExporter graphiteExporter(GraphiteConfig config,
|
||||
HierarchicalNameMapper nameMapper, Clock clock) {
|
||||
return () -> new GraphiteMeterRegistry(config, nameMapper, clock);
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "metrics.graphite")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.graphite")
|
||||
public class GraphiteProperties extends RegistryProperties implements GraphiteConfig {
|
||||
|
||||
@Override
|
||||
public String prefix() {
|
||||
return "metrics.graphite";
|
||||
return "spring.metrics.graphite";
|
||||
}
|
||||
|
||||
public void setStep(Duration step) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Import;
|
|||
public class InfluxExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.influx.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.influx.enabled", matchIfMissing = true)
|
||||
public MetricsExporter influxExporter(InfluxConfig config, Clock clock) {
|
||||
return () -> new InfluxMeterRegistry(config, clock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "metrics.influx")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.influx")
|
||||
public class InfluxProperties extends StepRegistryProperties implements InfluxConfig {
|
||||
|
||||
@Override
|
||||
public String prefix() {
|
||||
return "metrics.influx";
|
||||
return "spring.metrics.influx";
|
||||
}
|
||||
|
||||
public void setDb(String db) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class JmxExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.jmx.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.jmx.enabled", matchIfMissing = true)
|
||||
public MetricsExporter jmxExporter(HierarchicalNameMapper nameMapper, Clock clock) {
|
||||
return () -> new JmxMeterRegistry(nameMapper, clock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class PrometheusExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.prometheus.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.prometheus.enabled", matchIfMissing = true)
|
||||
public MetricsExporter prometheusExporter(PrometheusConfig config,
|
||||
CollectorRegistry collectorRegistry, Clock clock) {
|
||||
return () -> new PrometheusMeterRegistry(config, collectorRegistry, clock);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "metrics.prometheus")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.prometheus")
|
||||
public class PrometheusProperties extends RegistryProperties implements PrometheusConfig {
|
||||
|
||||
private boolean enabled = true;
|
||||
|
|
@ -46,7 +46,7 @@ public class PrometheusProperties extends RegistryProperties implements Promethe
|
|||
|
||||
@Override
|
||||
public String prefix() {
|
||||
return "metrics.prometheus";
|
||||
return "spring.metrics.prometheus";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class SimpleExportConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "metrics.simple.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.metrics.simple.enabled", matchIfMissing = true)
|
||||
@ConditionalOnMissingBean(MetricsExporter.class)
|
||||
public MetricsExporter simpleExporter(Clock clock) {
|
||||
return () -> new SimpleMeterRegistry(clock);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "metrics.simple")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.simple")
|
||||
public class SimpleProperties {
|
||||
|
||||
private boolean enabled = true;
|
||||
|
|
|
|||
|
|
@ -39,10 +39,13 @@ public class SimpleExportConfigurationTests {
|
|||
@Test
|
||||
public void simpleMeterRegistryIsInTheCompositeWhenNoOtherRegistryIs() {
|
||||
new ApplicationContextRunner()
|
||||
.withPropertyValues("metrics.atlas.enabled=false",
|
||||
"metrics.datadog.enabled=false", "metrics.ganglia.enabled=false",
|
||||
"metrics.graphite.enabled=false", "metrics.influx.enabled=false",
|
||||
"metrics.jmx.enabled=false", "metrics.prometheus.enabled=false")
|
||||
.withPropertyValues("spring.metrics.atlas.enabled=false",
|
||||
"spring.metrics.datadog.enabled=false",
|
||||
"spring.metrics.ganglia.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))
|
||||
.run((context) -> {
|
||||
CompositeMeterRegistry meterRegistry = context
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
# 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.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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue