Currently the performance/statistics of a method/API operation invocation are measured using simple
long start = System.currentTimeMillis();
doOperation();
long stop = System.currentTimeMillis();
long duration = stop - start;
...
we should streamline this kind of application insight and integrate a metrics suite (don't mix that up with the MELA measured metrics!) such as Codahale Metrics or Netflix Servo
for Codahale integration, those are the required maven dependencies:
Now we can annotate our methods with com.codahale.metrics.annotation.ExceptionMetered, com.codahale.metrics.annotation.Gauge, com.codahale.metrics.annotation.Metered and com.codahale.metrics.annotation.Timed. Additionally, we need to add the following to web.xml:
Currently the performance/statistics of a method/API operation invocation are measured using simple
we should streamline this kind of application insight and integrate a metrics suite (don't mix that up with the MELA measured metrics!) such as Codahale Metrics or Netflix Servo
for Codahale integration, those are the required maven dependencies:
Now we can annotate our methods with
com.codahale.metrics.annotation.ExceptionMetered
,com.codahale.metrics.annotation.Gauge
,com.codahale.metrics.annotation.Metered
andcom.codahale.metrics.annotation.Timed
. Additionally, we need to add the following toweb.xml
:for this to work, we also need a
MetricsRegistry
initializer which sets the correctREGISTRY_NAME
attribute:and add one last thing to web.xml
that should be it.