java 在服务方法中使用@Timed

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29896424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 16:05:44  来源:igfitidea点击:

Using @Timed in service method

javaspringspring-bootmetrics

提问by jfcorugedo

I'm working with Spring Boot, and I want to annotate some of my @Servicemethods with @Timedso I could view their statistics calling the metrics endpoint.

我正在使用 Spring Boot,我想用它来注释我的一些@Service方法,@Timed以便我可以查看它们调用指标端点的统计信息。

I've read from the Spring documentation that is can use dropwizard registry, but I can't find any example in which it uses dropwizar annotations.

我已经阅读了可以使用 dropwizard 注册表的 Spring 文档,但是我找不到任何使用 dropwizar 注释的示例。

How can I configure my Spring Boot app so each method annotated with @Timedautomatically publishes its statistics using the build-in Spring actuator module?

如何配置我的 Spring Boot 应用程序,以便@Timed使用内置 Spring 执行器模块自动发布其统计信息?

采纳答案by Shawn Clark

Have you had a look at: http://www.ryantenney.com/metrics-spring/

你有没有看过:http: //www.ryantenney.com/metrics-spring/

Seems that you need to include that library if you want to use Spring with Metrics 3.0 / 3.1.

如果您想将 Spring 与 Metrics 3.0 / 3.1 一起使用,似乎您需要包含该库。