I use @Timed
annotation on String Boot rest controller and it works fine. Method from controller calls method from service which is also annotated with @Timed
.
However, this annotation on method in subsequent service bean doesn't work (I don't see results in /metrics
). Why is it happening? Could it be fixed?
As per Support for @Timed in any Spring-managed bean #361 you can get this behaviour by registering TimedAspect
manually.
@Configuration
@EnableAspectJAutoProxy
public class AutoTimingConfiguration {
@Bean
public TimedAspect timedAspect(MeterRegistry registry) {
return new TimedAspect(registry);
}
}
Do note that as per jkschneider comment in #361:
We can revisit application of @Timed via AOP or a BPP in Boot 2.1, depending on how the community reacts to the feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With