Merge pull request #12127 from jkschneider:micrometer-449
* pr/12127: Polish "Consistent prefix for datasource pool metrics" Consistent prefix for datasource pool metrics
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class DataSourcePoolMetrics implements MeterBinder {
|
||||
private <N extends Number> void bindDataSource(MeterRegistry registry,
|
||||
String metricName, Function<DataSource, N> 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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user