I am trying to setup metrics-spring to work in a Spring Boot application. To do this I added following dependencies:
compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.2.2'
compile group: 'io.dropwizard.metrics', name: 'metrics-annotation', version: '3.2.2'
compile group: 'com.ryantenney.metrics', name: 'metrics-spring', version: '3.1.3'
compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.10'
compile group: 'cglib', name: 'cglib-nodep', version: '3.2.5'
compile group: 'org.springframework', name: 'spring-aop'
Created a configuration for metrics:
@EnableMetrics(proxyTargetClass = true)
@Configuration
@Slf4j
@CompileStatic
class SpringConfig extends MetricsConfigurerAdapter {
@Override
void configureReporters(MetricRegistry metricRegistry) {
// registerReporter allows the MetricsConfigurerAdapter to
// shut down the reporter when the Spring context is closed
registerReporter(ConsoleReporter
.forRegistry(metricRegistry)
.build())
.start(20, TimeUnit.SECONDS)
}
}
And added a @Timed annotation:
@POST
@Path('auth')
@Timed(absolute = true, name = 'api.auth.createAuthToken')
Response auth(Credentials credentials) {
}
But I receive no metrics: 15/06/17 18:06:10 ==============================================================
On the other hand if I manually create a Timer and provide time to it it works fine.
I assume that it does not work because metrics-spring does not create AOP proxies for annotated methods, but I am not sure why.
Do you know what should I do to enable it?