|
|
@ -54,19 +54,16 @@ public class DataSourcePoolMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void autoConfiguredDataSourceIsInstrumented() {
|
|
|
|
public void autoConfiguredDataSourceIsInstrumented() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
context.getBean(DataSource.class).getConnection().getMetaData();
|
|
|
|
context.getBean(DataSource.class).getConnection().getMetaData();
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
registry.get("jdbc.connections.max").tags("name", "dataSource")
|
|
|
|
registry.get("jdbc.connections.max").tags("name", "dataSource").meter();
|
|
|
|
.meter();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void dataSourceInstrumentationCanBeDisabled() {
|
|
|
|
public void dataSourceInstrumentationCanBeDisabled() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner.withPropertyValues("management.metrics.enable.jdbc=false")
|
|
|
|
.withPropertyValues("management.metrics.enable.jdbc=false")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
context.getBean(DataSource.class).getConnection().getMetaData();
|
|
|
|
context.getBean(DataSource.class).getConnection().getMetaData();
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
@ -92,8 +89,7 @@ public class DataSourcePoolMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void autoConfiguredHikariDataSourceIsInstrumented() {
|
|
|
|
public void autoConfiguredHikariDataSourceIsInstrumented() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
|
|
|
|
context.getBean(DataSource.class).getConnection();
|
|
|
|
context.getBean(DataSource.class).getConnection();
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
registry.get("hikaricp.connections").meter();
|
|
|
|
registry.get("hikaricp.connections").meter();
|
|
|
@ -102,13 +98,11 @@ public class DataSourcePoolMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void hikariDataSourceInstrumentationCanBeDisabled() {
|
|
|
|
public void hikariDataSourceInstrumentationCanBeDisabled() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner.withPropertyValues("management.metrics.enable.hikaricp=false")
|
|
|
|
.withPropertyValues("management.metrics.enable.hikaricp=false")
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
context.getBean(DataSource.class).getConnection();
|
|
|
|
context.getBean(DataSource.class).getConnection();
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
MeterRegistry registry = context.getBean(MeterRegistry.class);
|
|
|
|
assertThat(registry.find("hikaricp.connections").meter())
|
|
|
|
assertThat(registry.find("hikaricp.connections").meter()).isNull();
|
|
|
|
.isNull();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -215,8 +209,7 @@ public class DataSourcePoolMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
private org.apache.tomcat.jdbc.pool.DataSource createTomcatDataSource() {
|
|
|
|
private org.apache.tomcat.jdbc.pool.DataSource createTomcatDataSource() {
|
|
|
|
String url = "jdbc:hsqldb:mem:test-" + UUID.randomUUID();
|
|
|
|
String url = "jdbc:hsqldb:mem:test-" + UUID.randomUUID();
|
|
|
|
return DataSourceBuilder
|
|
|
|
return DataSourceBuilder.create().url(url)
|
|
|
|
.create().url(url)
|
|
|
|
|
|
|
|
.type(org.apache.tomcat.jdbc.pool.DataSource.class).build();
|
|
|
|
.type(org.apache.tomcat.jdbc.pool.DataSource.class).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|