Search in sources :

Example 1 with DefaultMetricsFactory

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;
}
Also used : DefaultMetricsFactory(org.springframework.integration.support.management.DefaultMetricsFactory) MessageSourceMetricsConfigurer(org.springframework.integration.support.management.MessageSourceMetricsConfigurer) DefaultMetricsFactory(org.springframework.integration.support.management.DefaultMetricsFactory) MetricsFactory(org.springframework.integration.support.management.MetricsFactory) IntegrationManagement(org.springframework.integration.support.management.IntegrationManagement)

Aggregations

DefaultMetricsFactory (org.springframework.integration.support.management.DefaultMetricsFactory)1 IntegrationManagement (org.springframework.integration.support.management.IntegrationManagement)1 MessageSourceMetricsConfigurer (org.springframework.integration.support.management.MessageSourceMetricsConfigurer)1 MetricsFactory (org.springframework.integration.support.management.MetricsFactory)1