pull/16246/head
Phillip Webb 6 years ago
parent fa84414421
commit 74376aa023

@ -59,17 +59,15 @@ class HikariDataSourceMetricsPostProcessor implements BeanPostProcessor, Ordered
}
private HikariDataSource determineHikariDataSource(Object bean) {
if (!(bean instanceof DataSource)) {
return null;
if (bean instanceof DataSource) {
return DataSourceUnwrapper.unwrap((DataSource) bean, HikariDataSource.class);
}
DataSource dataSource = (DataSource) bean;
return DataSourceUnwrapper.unwrap(dataSource, HikariDataSource.class);
return null;
}
private void bindMetricsRegistryToHikariDataSource(MeterRegistry registry,
HikariDataSource dataSource) {
if (dataSource.getMetricRegistry() == null
&& dataSource.getMetricsTrackerFactory() == null) {
if (!hasExisingMetrics(dataSource)) {
try {
dataSource.setMetricsTrackerFactory(
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() {
if (this.meterRegistry == null) {
this.meterRegistry = this.context.getBean(MeterRegistry.class);

@ -105,6 +105,9 @@ public class WebMvcMetricsAutoConfiguration {
return new MetricsWebMvcConfigurer(meterRegistry, tagsProvider);
}
/**
* {@link WebMvcConfigurer} to add metrics interceptors.
*/
static class MetricsWebMvcConfigurer implements WebMvcConfigurer {
private final MeterRegistry meterRegistry;

@ -109,16 +109,6 @@ public class JerseyAutoConfiguration implements ServletContextAware {
customize();
}
private String resolveApplicationPath() {
if (StringUtils.hasLength(this.jersey.getApplicationPath())) {
return this.jersey.getApplicationPath();
}
else {
return findApplicationPath(AnnotationUtils.findAnnotation(
this.config.getApplication().getClass(), ApplicationPath.class));
}
}
private void customize() {
if (this.customizers != null) {
AnnotationAwareOrderComparator.sort(this.customizers);
@ -134,6 +124,14 @@ public class JerseyAutoConfiguration implements ServletContextAware {
return this::resolveApplicationPath;
}
private String resolveApplicationPath() {
if (StringUtils.hasLength(this.jersey.getApplicationPath())) {
return this.jersey.getApplicationPath();
}
return findApplicationPath(AnnotationUtils.findAnnotation(
this.config.getApplication().getClass(), ApplicationPath.class));
}
@Bean
@ConditionalOnMissingBean
public FilterRegistrationBean<RequestContextFilter> requestContextFilter() {

Loading…
Cancel
Save