I have an Spring Boot application integrated with Dropwizard Metrics following this link.
When I added the @Timed
annotation into some APIs (controller methods) it showed on the metrics link.
For example, for below RestController
:
@RestController
public class TestController {
@GET
@Path("/ping")
@Timed
@ApiOperation("Ping server")
public Response Ping() {
return Response.ok().build();
}
}
then result is as follows:
"timers": {
"com.test.testcontroller.Ping": {
"count": 0,
"max": 0.0,
"mean": 0.0,
"min": 0.0,
"p50": 0.0,
"p75": 0.0,
"p95": 0.0,
"p98": 0.0,
"p99": 0.0,
"p999": 0.0,
"stddev": 0.0,
"m15_rate": 0.0,
"m1_rate": 0.0,
"m5_rate": 0.0,
"mean_rate": 0.0,
"duration_units": "seconds",
"rate_units": "calls/second"
}
}
I have around 20 controllers with a total of 130 APIs (methods) so I would like to configure a wide annotation or inject the @Timed
annotation automatically. Something like:
@RestController
@Timed
public class TestController {
@GET
@Path("/ping")
@ApiOperation("Ping server")
// timed will auto applied in here
public Response Ping() {
return Response.ok().build();
}
}
How can I achieve that?