简体   繁体   English

@Timed注释弹簧指标

[英]@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.

相关问题 Codahale指标:在普通Java中使用@Timed指标注释 - Codahale Metrics: using @Timed metrics annotation in plain Java 获取@ Timedmetrics-spring的2个相同的拦截器AndDynamicMethodMatchers - get the 2 identical interceptorsAndDynamicMethodMatchers for @Timed metrics-spring Spring 中的注释处理顺序(@Cacheable 和 @Timed) - Order of annotation processing in Spring (@Cacheable and @Timed) Java + Micrometer @Timed annotation + Spring 反应 @Repository 可能吗? - Java + Micrometer @Timed annotation + Spring reactive @Repository possible? 如何自动将 Dropwizard Metrics @Timed 添加到 spring 启动应用程序中的所有 API 方法中? - How to automatically add Dropwizard Metrics @Timed into all APIs method in spring boot application? 千分尺@Timed 注释 - Micrometer @Timed annotation 是否有一些功能可以记录/计算 spring weblfux 中模块的时间延迟? 例如使用@Timed 注释 - Is there some functionality to log/calculate time latencies of modules in spring weblfux? For e.g. using @Timed annotation Spring AOP:@annotation(annotation) - Spring AOP: @annotation(annotation) 在spring boot中导出指标 - Exporting metrics in spring boot 春季4 +球衣2 +指标 - Spring 4 + Jersey 2 + Metrics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM