[英]@Timed annotation in spring metrics
I use @Timed
annotation on String Boot rest controller and it works fine. 我在String Boot rest控制器上使用@Timed
注释,它工作正常。 Method from controller calls method from service which is also annotated with @Timed
. 来自服务的控制器调用方法的方法,该方法也使用@Timed
注释。
However, this annotation on method in subsequent service bean doesn't work (I don't see results in /metrics
). 但是,后续服务bean中的方法的这个注释不起作用(我没有在/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. 根据任何Spring管理的bean#361中对@Timed的支持,您可以通过手动注册TimedAspect
来获得此行为。
@Configuration
@EnableAspectJAutoProxy
public class AutoTimingConfiguration {
@Bean
public TimedAspect timedAspect(MeterRegistry registry) {
return new TimedAspect(registry);
}
}
Do note that as per jkschneider comment in #361: 请注意,根据#361中的jkschneider评论:
We can revisit application of @Timed via AOP or a BPP in Boot 2.1, depending on how the community reacts to the feature. 我们可以在Boot 2.1中通过AOP或BPP重新审视@Timed的应用,具体取决于社区对该功能的反应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.