|
|
@ -59,17 +59,15 @@ class HikariDataSourceMetricsPostProcessor implements BeanPostProcessor, Ordered
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private HikariDataSource determineHikariDataSource(Object bean) {
|
|
|
|
private HikariDataSource determineHikariDataSource(Object bean) {
|
|
|
|
if (!(bean instanceof DataSource)) {
|
|
|
|
if (bean instanceof DataSource) {
|
|
|
|
return null;
|
|
|
|
return DataSourceUnwrapper.unwrap((DataSource) bean, HikariDataSource.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DataSource dataSource = (DataSource) bean;
|
|
|
|
return null;
|
|
|
|
return DataSourceUnwrapper.unwrap(dataSource, HikariDataSource.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void bindMetricsRegistryToHikariDataSource(MeterRegistry registry,
|
|
|
|
private void bindMetricsRegistryToHikariDataSource(MeterRegistry registry,
|
|
|
|
HikariDataSource dataSource) {
|
|
|
|
HikariDataSource dataSource) {
|
|
|
|
if (dataSource.getMetricRegistry() == null
|
|
|
|
if (!hasExisingMetrics(dataSource)) {
|
|
|
|
&& dataSource.getMetricsTrackerFactory() == null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
dataSource.setMetricsTrackerFactory(
|
|
|
|
dataSource.setMetricsTrackerFactory(
|
|
|
|
new MicrometerMetricsTrackerFactory(registry));
|
|
|
|
new MicrometerMetricsTrackerFactory(registry));
|
|
|
@ -80,6 +78,11 @@ class HikariDataSourceMetricsPostProcessor implements BeanPostProcessor, Ordered
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean hasExisingMetrics(HikariDataSource dataSource) {
|
|
|
|
|
|
|
|
return dataSource.getMetricRegistry() != null
|
|
|
|
|
|
|
|
|| dataSource.getMetricsTrackerFactory() != null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private MeterRegistry getMeterRegistry() {
|
|
|
|
private MeterRegistry getMeterRegistry() {
|
|
|
|
if (this.meterRegistry == null) {
|
|
|
|
if (this.meterRegistry == null) {
|
|
|
|
this.meterRegistry = this.context.getBean(MeterRegistry.class);
|
|
|
|
this.meterRegistry = this.context.getBean(MeterRegistry.class);
|
|
|
|