Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

metrics for my api powered by jersey

Tags:

jersey

metrics

I try to instrumente my Jersey webservice with Metrics

http://metrics.codahale.com/manual/jersey/

I don't understand how to use this library? Do I need to add something in my web.xml file?

Thanks

like image 214
Julien Avatar asked Mar 29 '12 12:03

Julien


1 Answers

To instrument your Jersey web service, you must add the metrics-jersey module to your application, it contains a @Provider implementation class (make sure Jersey find it) that allow you to instrument your Jersey resources methods annotated with @Timed, Metered and ExceptionMetered.

By default, Metrics reports through JMX, so you can use JConsole to validate your instrumentations. Like Alex wrote, there are others reporting options but it requires additional configuration or code (call enable method on the Reporter). For example you can fetch reports in JSON by HTTP, or have you webservice send reports to a monitoring server such as Graphite.

like image 120
Le Hibou Avatar answered Nov 15 '22 11:11

Le Hibou