Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using @Timed in service method

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?

like image 743
jfcorugedo Avatar asked Apr 27 '15 12:04

jfcorugedo


People also ask

What is the use of @timed annotation in spring boot?

Adding @Timed to the controller creates a Timer time series named http_server_requests which by default contains dimensions for the HTTP status of the response, HTTP method, exception type if the request fails, and the pre-variable substitution parameterized endpoint URI.

What is @ExceptionMetered?

* @ExceptionMetered - As the name indicates, this will create a Meter of the unhandled Exceptions thrown out of this method. This is SUPER useful for tracking error rates, and can be used together with @Timed or @Metered annotations, or entirely by itself.

What is spring boot micrometer?

Micrometer provides a simple facade over the instrumentation clients for a number of popular monitoring systems. Currently, it supports the following monitoring systems: Atlas, Datadog, Graphite, Ganglia, Influx, JMX, and Prometheus.

What are spring boot metrics?

Spring Boot provides a metrics endpoint that can be used diagnostically to examine the metrics collected by an application. The endpoint is not available by default and must be exposed, see exposing endpoints for more details. Navigating to /actuator/metrics displays a list of available meter names.


1 Answers

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.

like image 111
Shawn Clark Avatar answered Sep 18 '22 06:09

Shawn Clark