Using @Timed in service method

jfcorugedo picture jfcorugedo · Apr 27, 2015 · Viewed 17.3k times · Source

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

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.

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

Answer

Shawn Clark picture Shawn Clark · Apr 30, 2015

Have you had a look at: 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.