ryantenney / metrics-spring

Spring integration for Metrics
http://www.ryantenney.com/metrics-spring/
Apache License 2.0
701 stars 226 forks source link

Possible Issue #213

Open safaci2000 opened 6 years ago

safaci2000 commented 6 years ago

I'm trying to create an internal library that contains most of the dependencies that we need for monitoring, basic utilities and configurations that we have for our apps.

My library includes: metrics-spring, metrics-core, and spring-aop.

My app contains my library and spring-aop.

IF I include metrics-spring on a specific app everything works fine.

My configuration is very simple just doing console metrics.

IF I all the required classes are in the App itself everything works fine, but as soon as I pull anything out into a maven library the monitoring is not triggered and the breakpoint on:

private void enableLogReporting(MetricRegistry metricRegistry) { // code } 

Is never triggered in the library version of the configuration.

I hope this is too specialized of a use case, but I don't think I'm doing anything that unusual that it would fail to work.

Have I missed an obvious step in order to use metrics-spring as part of a library?

Current Configuration:

@Configuration
@EnableMetrics
public class TestingConfig extends MetricsConfigurerAdapter {

  @Override
  public void configureReporters(MetricRegistry metricRegistry) {
    MetricRegistry registry = SharedMetricRegistries.add("main", metricRegistry);
    registerReporter(ConsoleReporter
        .forRegistry(metricRegistry)
        .build())
    }

}

Main class config:

@Configuration
@Import({TestingConfig.class})
@ComponentScan(basePackageClasses = {
    AppConfig.class
})
public class AppConfig {

   // more code / beans here
}

The only difference between the two attempts is that the TestingConfig.class is inside my library instead of in my project and that immediate makes my setup non-functional.

Any thoughts?