I am a newbee to Coda Hale Metrics. I have created a sample spring app which is having a simple RESTful web service method.
I have used Meter, Timer and Counter tools provided by Coda Hale Metrics framework, to track the number of requests, request ratio and request duration. Currently I output these info to the console by using the Console Reporter of Metrics (please find the code below).
@Override
public void configureReporters(MetricRegistry metricRegistry) {
registerReporter(ConsoleReporter.forRegistry(metricRegistry).build())
.start(30, TimeUnit.SECONDS);
}
I have few questions regarding Coda Hale Metrics.
(1) Currently the Counter shows the total no. of request made since the server is up. Are there any way to get the no. of requests made in a specific reporting period (ex:- count for 1st 30 seconds = count1, count for 2nd 30 seconds = count2, etc...)
(2) Is it possible to get the duration of each request using Timer? Currently Timer shows min, max and average rates of all the requests being made.
(3) Are there any possibilities to persist those Metrics data into an external DB (ex:- MySQL)?
Below is my REST service method.
@RequestMapping(value = "/examplerest", method = RequestMethod.GET)
@ResponseBody
@Metered(name="exampleRestMetered")
@Timed(name="exampleRestTimed")
@Counted(name="exampleRestCounted", monotonic=true)
public String exampleRest(
HttpServletResponse response) {
/**
some logics here
*/
}
I appreciate your guidance on this.
Thanks.