From 8704cf1fe78d156de9beb7355c7185bd22078155 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 18 Jan 2018 17:21:40 +0100 Subject: [PATCH] Harmonize metric property names See gh-11667 --- .../metrics/cache/CacheMetricsProperties.java | 10 +++++----- .../cache/CacheMetricsRegistrarConfiguration.java | 2 +- .../jdbc/DataSourcePoolMetricsConfiguration.java | 2 +- .../metrics/jdbc/JdbcMetricsProperties.java | 12 ++++++------ .../metrics/MetricsAutoConfigurationTests.java | 2 +- .../cache/CacheMetricsConfigurationTests.java | 2 +- .../asciidoc/appendix-application-properties.adoc | 4 ++-- .../src/main/asciidoc/production-ready-features.adoc | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsProperties.java index 2a2833020cb..58199f3db60 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsProperties.java @@ -30,14 +30,14 @@ public class CacheMetricsProperties { /** * Name of the metric for cache usage. */ - private String cacheMetricName = "cache"; + private String metricName = "cache"; - public String getCacheMetricName() { - return this.cacheMetricName; + public String getMetricName() { + return this.metricName; } - public void setCacheMetricName(String cacheMetricName) { - this.cacheMetricName = cacheMetricName; + public void setMetricName(String metricName) { + this.metricName = metricName; } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java index c7052582f7c..cc6db5fb917 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java @@ -66,7 +66,7 @@ class CacheMetricsRegistrarConfiguration { @Bean public CacheMetricsRegistrar cacheMetricsRegistrar() { return new CacheMetricsRegistrar(this.registry, - this.properties.getCacheMetricName(), this.binderProviders); + this.properties.getMetricName(), this.binderProviders); } @PostConstruct diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java index 473c91a7e7f..96d2e559f7b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsConfiguration.java @@ -60,7 +60,7 @@ public class DataSourcePoolMetricsConfiguration { JdbcMetricsProperties jdbcMetricsProperties) { this.registry = registry; this.metadataProviders = metadataProviders; - this.metricName = jdbcMetricsProperties.getDatasourceMetricName(); + this.metricName = jdbcMetricsProperties.getMetricName(); } @Autowired diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/JdbcMetricsProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/JdbcMetricsProperties.java index 6bd65513d11..8d839e0a039 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/JdbcMetricsProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/JdbcMetricsProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,14 +30,14 @@ public class JdbcMetricsProperties { /** * Name of the metric for data source usage. */ - private String datasourceMetricName = "data.source"; + private String metricName = "data.source"; - public String getDatasourceMetricName() { - return this.datasourceMetricName; + public String getMetricName() { + return this.metricName; } - public void setDatasourceMetricName(String datasourceMetricName) { - this.datasourceMetricName = datasourceMetricName; + public void setMetricName(String metricName) { + this.metricName = metricName; } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java index 30b7341e0ce..c2c520768c2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationTests.java @@ -65,7 +65,7 @@ public class MetricsAutoConfigurationTests { .withConfiguration( AutoConfigurations.of(DataSourceAutoConfiguration.class)) .withPropertyValues("spring.datasource.generate-unique-name=true", - "management.metrics.jdbc.datasource-metric-name=custom.name") + "management.metrics.jdbc.metric-name=custom.name") .run((context) -> { context.getBean(DataSource.class).getConnection().getMetaData(); MeterRegistry registry = context.getBean(MeterRegistry.class); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java index 62a5bc636fe..43d4d5811f7 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsConfigurationTests.java @@ -59,7 +59,7 @@ public class CacheMetricsConfigurationTests { public void autoConfiguredCacheManagerWithCustomMetricName() { this.contextRunner .withPropertyValues( - "management.metrics.cache.cache-metric-name=custom.name", + "management.metrics.cache.metric-name=custom.name", "spring.cache.type=caffeine", "spring.cache.cache-names=cache1") .run((context) -> { MeterRegistry registry = context.getBean(MeterRegistry.class); diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 289023c09de..e7adcd9c8fd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1281,7 +1281,7 @@ content into your application. Rather, pick only the properties that you need. management.metrics.binders.logback.enabled=true # Whether to enable Logback metrics. management.metrics.binders.processor.enabled=true # Whether to enable processor metrics. management.metrics.binders.uptime.enabled=true # Whether to enable uptime metrics. - management.metrics.cache.cache-metric-name=cache # Name of the metric for cache usage. + management.metrics.cache.metric-name=cache # Name of the metric for cache usage. management.metrics.cache.instrument=true # Instrument all available caches. management.metrics.export.atlas.batch-size= # Number of measurements per request to use for the backend. If more measurements are found, then multiple requests will be made. management.metrics.export.atlas.config-refresh-frequency= # Frequency for refreshing config settings from the LWC service. @@ -1351,7 +1351,7 @@ content into your application. Rather, pick only the properties that you need. management.metrics.export.statsd.polling-frequency=10s # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed, it is sent to the StatsD server. management.metrics.export.statsd.port=8125 # Port of the StatsD server to receive exported metrics. management.metrics.export.statsd.queue-size=2147483647 # Maximum size of the queue of items waiting to be sent to the StatsD server. - management.metrics.jdbc.datasource-metric-name=data.source # Name of the metric for data source usage. + management.metrics.jdbc.metric-name=data.source # Name of the metric for data source usage. management.metrics.jdbc.instrument=true # Instrument all available data sources. management.metrics.rabbitmq.instrument=true # Instrument all available connection factories. management.metrics.rabbitmq.metric-name=rabbitmq # Name of the metric for RabbitMQ usage. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index c7ff9a017d0..91d1f917426 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -1035,7 +1035,7 @@ following information: === Cache metrics Auto-configuration will enable the instrumentation of all available ``Cache``s on startup with a metric named `cache`. The prefix can be customized by using the -`management.metrics.cache.cache-metric-name` property. Cache instrumentation is specific +`management.metrics.cache.metric-name` property. Cache instrumentation is specific to each cache library, refer to https://micrometer.io/docs[the micrometer documentation] for more details. @@ -1061,7 +1061,7 @@ Auto-configuration enables the instrumentation of all available ``DataSource`` o with a metric named `data.source`. Data source instrumentation results in gauges representing the currently active, maximum allowed, and minimum allowed connections in the pool. Each of these gauges has a name that is prefixed by `data.source` by default. The -prefix can be customized by setting the `management.metrics.jdbc.datasource-metric-name` +prefix can be customized by setting the `management.metrics.jdbc.metric-name` property. Metrics are also tagged by the name of the `DataSource` computed based on the bean name.