package org.axonframework.boot.autoconfig;

import com.codahale.metrics.MetricRegistry;
import org.axonframework.metrics.GlobalMetricRegistry;
import org.axonframework.metrics.MetricsModuleConfigurer;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Auto configuration to set up Metrics for the infrastructure components.
 *
 * @author Steven van Beelen
 * @since 3.2
 */
@Configuration
//TODO search for the Spring Factory creating the MetricRegistry bean
@AutoConfigureBefore(AxonAutoConfiguration.class)
@ConditionalOnClass(name = {
        "com.codahale.metrics.MetricRegistry",
        "org.axonframework.metrics.GlobalMetricRegistry"
})
public class MetricsAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public MetricRegistry metricRegistry() {
        return new MetricRegistry();
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnBean(MetricRegistry.class)
    public GlobalMetricRegistry globalMetricRegistry(MetricRegistry metricRegistry) {
        return new GlobalMetricRegistry(metricRegistry);
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnBean(GlobalMetricRegistry.class)
    public MetricsModuleConfigurer metricsModuleConfigurer(GlobalMetricRegistry globalMetricRegistry) {
        return new MetricsModuleConfigurer(globalMetricRegistry);
    }
}


@@ -194,16 +194,82 @@
 igurer;%0A
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;%0A
 import o
@@ -822,77 +822,119 @@
 ion%0A
-//TODO search for the Spring Factory creating the MetricRegistry bean
+@AutoConfigureAfter(name = %22org.springframework.boot.actuate.autoconfigure.MetricsDropwizardAutoConfiguration%22)
 %0A@Au

Replace TODO for a AutoConfigureAfter MetricsDropwizardAutoConfiguration