Example of using the metrics library in a JAX-RS, RESTEasy and Spring service. Utilising the following metrics libraries:
- metrics-annotation : for annotating JAX-RS resource methods and other functions with metrics annotations
- metrics-spring: for scanning and loading metrics annotated Spring components into the metric registry, and loading healthchecks into the healthcheck registry
- metrics-servlet: for instrumenting servlet calls using an instrumented filter
- metrics-servlets: for providing reporting servlets over the metric & health check registries
- metrics-httpclient: for use of an instrumented http client for downstream http calls
- metrics watcher : some HTML, CSS and JS for visualising some of the metrics produced by the metrics-servlets.
To get it running:
-
Install JBoss 7/EAP on localhost
-
Start a standalone instance of JBoss
./bin/standalone.sh -b 0.0.0.0
-
Build the HTTP service stub
mvn clean package
-
Deploy the HTTP service stub to standalone deployments folder
-
Build the metrics-customer-api
mvn clean package
-
Deploy the metrics-customer-api WAR to standalone deployments folder
-
POST a customer via a REST client to
http://localhost:8080/metrics-customer-api/api/customers
Content-Type header: application/json
{ "id": "2", "firstName": "John", "lastName": "Doe" }
-
GET a customer via a REST client
-
Visit the metrics admin page and check the metrics, ping and health check sub-links all work
-
Visit the prettier metrics watcher page: