package org.axonframework.boot.autoconfig;

import com.codahale.metrics.MetricRegistry;
import org.axonframework.metrics.GlobalMetricRegistry;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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
@AutoConfigureBefore(AxonAutoConfiguration.class)
public class MetricsAutoConfiguration {

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

@@ -110,36 +110,143 @@
 ork.
-metrics.GlobalMetricRegistry
+config.Configurer;%0Aimport org.axonframework.metrics.GlobalMetricRegistry;%0Aimport org.springframework.beans.factory.annotation.Autowired
 ;%0Aim
@@ -1049,11 +1049,199 @@
 );%0A    %7D
+%0A%0A    @Autowired%0A    public void configureMetrics(GlobalMetricRegistry globalMetricRegistry, Configurer configurer) %7B%0A        globalMetricRegistry.registerWithConfigurer(configurer);%0A    %7D
 %0A%7D%0A

Add @Autowired configureMetrics function