use of org.springframework.integration.support.management.DefaultMetricsFactory in project spring-integration by spring-projects.
the class IntegrationManagementConfigurer method afterSingletonsInstantiated.
@Override
public void afterSingletonsInstantiated() {
Assert.state(this.applicationContext != null, "'applicationContext' must not be null");
Assert.state(MANAGEMENT_CONFIGURER_NAME.equals(this.beanName), getClass().getSimpleName() + " bean name must be " + MANAGEMENT_CONFIGURER_NAME);
ClassLoader classLoader = IntegrationManagementConfigurer.class.getClassLoader();
if (ClassUtils.isPresent("io.micrometer.core.instrument.MeterRegistry", classLoader)) {
this.metricsCaptor = MicrometerMetricsCaptor.loadCaptor(this.applicationContext);
}
if (this.metricsCaptor != null) {
injectCaptor();
registerComponentGauges();
}
if (this.metricsFactory == null && StringUtils.hasText(this.metricsFactoryBeanName)) {
this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName, MetricsFactory.class);
}
if (this.metricsFactory == null) {
Map<String, MetricsFactory> factories = this.applicationContext.getBeansOfType(MetricsFactory.class);
if (factories.size() == 1) {
this.metricsFactory = factories.values().iterator().next();
}
}
if (this.metricsFactory == null) {
this.metricsFactory = new DefaultMetricsFactory();
}
this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType(MessageSourceMetricsConfigurer.class));
Map<String, IntegrationManagement> managed = this.applicationContext.getBeansOfType(IntegrationManagement.class);
for (Entry<String, IntegrationManagement> entry : managed.entrySet()) {
IntegrationManagement bean = entry.getValue();
if (!bean.getOverrides().loggingConfigured) {
bean.setLoggingEnabled(this.defaultLoggingEnabled);
}
String name = entry.getKey();
doConfigureMetrics(bean, name);
}
this.singletonsInstantiated = true;
}
Aggregations