From 16867f866c14b94f87830b5357b72de4f584a4f1 Mon Sep 17 00:00:00 2001 From: Jon Schneider Date: Mon, 19 Feb 2018 21:24:17 -0600 Subject: [PATCH 1/2] Consistent prefix for datasource pool metrics See gh-12127 --- .../boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java | 2 +- .../boot/actuate/metrics/jdbc/DataSourcePoolMetricsTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java index 886a12e7aa..7952e8d931 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java @@ -84,7 +84,7 @@ public class DataSourcePoolMetrics implements MeterBinder { private void bindDataSource(MeterRegistry registry, String metricName, Function function) { if (function.apply(this.dataSource) != null) { - registry.gauge("jdbc." + metricName + ".connections", this.tags, + registry.gauge("jdbc.connections." + metricName, this.tags, this.dataSource, (m) -> function.apply(m).doubleValue()); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetricsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetricsTests.java index 6872119787..dedaf9de1c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetricsTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetricsTests.java @@ -50,7 +50,7 @@ public class DataSourcePoolMetricsTests { "metrics.use-global-registry=false") .run((context) -> { context.getBean(DataSource.class).getConnection().getMetaData(); - context.getBean(MeterRegistry.class).get("jdbc.max.connections") + context.getBean(MeterRegistry.class).get("jdbc.connections.max") .meter(); }); } From f19b43bacc7af4d7273e9d2ce9103fbf8c18a344 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 20 Feb 2018 10:07:00 +0100 Subject: [PATCH 2/2] Polish "Consistent prefix for datasource pool metrics" Closes gh-12127 --- .../jdbc/DataSourcePoolMetricsAutoConfigurationTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfigurationTests.java index c2a224ac03..e5f4b81784 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfigurationTests.java @@ -57,7 +57,7 @@ public class DataSourcePoolMetricsAutoConfigurationTests { .run((context) -> { context.getBean(DataSource.class).getConnection().getMetaData(); MeterRegistry registry = context.getBean(MeterRegistry.class); - registry.get("jdbc.max.connections").tags("name", "dataSource") + registry.get("jdbc.connections.max").tags("name", "dataSource") .meter(); }); } @@ -72,7 +72,7 @@ public class DataSourcePoolMetricsAutoConfigurationTests { .run((context) -> { context.getBean(DataSource.class).getConnection().getMetaData(); MeterRegistry registry = context.getBean(MeterRegistry.class); - assertThat(registry.find("jdbc.max.connections") + assertThat(registry.find("jdbc.connections.max") .tags("name", "dataSource").meter()).isNull(); }); } @@ -88,8 +88,8 @@ public class DataSourcePoolMetricsAutoConfigurationTests { context.getBean("secondOne", DataSource.class).getConnection() .getMetaData(); MeterRegistry registry = context.getBean(MeterRegistry.class); - registry.get("jdbc.max.connections").tags("name", "first").meter(); - registry.get("jdbc.max.connections").tags("name", "secondOne") + registry.get("jdbc.connections.max").tags("name", "first").meter(); + registry.get("jdbc.connections.max").tags("name", "secondOne") .meter(); }); }