@@ -10,10 +10,10 @@ Pippo provides optional integration with [Metrics](http://metrics.dropwizard.io/
1010
1111Pippo comes (out of the box) with some reporting backends:
1212
13- - [ Ganglia] ( /mod/metrics/ganglia.html ) ` pippo-metrics-ganglia `
1413- [ Graphite] ( /mod/metrics/graphite.html ) ` pippo-metrics-graphite `
1514- [ InfluxDB] ( /mod/metrics/influxdb.html ) ` pippo-metrics-influxdb `
1615- [ Librato] ( /mod/metrics/librato.html ) ` pippo-metrics-librato `
16+ - [ Prometheus] ( /mod/metrics/prometheus.html ) ` pippo-metrics-prometheus `
1717
1818#### Add the Pippo Metrics dependency
1919
@@ -31,7 +31,6 @@ Now you are ready to start annotating your route handler methods or controller m
3131
3232You have several choices in the collection of metrics:
3333
34- - * Do nothing*
3534- [ Counted] ({{ site.codeurl }}/pippo-metrics-parent/pippo-metrics/src/main/java/ro/pippo/metrics/Counted.java)
3635A counter increments (and optionally decrements) when a method is executed.
3736- [ Metered] ({{ site.codeurl }}/pippo-metrics-parent/pippo-metrics/src/main/java/ro/pippo/metrics/Metered.java)
@@ -43,6 +42,8 @@ A timer measures both the rate that a particular piece of code is called and the
43422 . Start up VisualVM (and install the MBeans plugin) or JConsole.
44433 . Browse your app and refresh the collected metrics.
4544
45+ See below how to add a metric (meter) on a route handler
46+
4647``` java
4748GET (" /" , new RouteHandler () {
4849
@@ -55,7 +56,42 @@ GET("/", new RouteHandler() {
5556});
5657```
5758
58- Or a controller example:
59+ Other possible variants
60+
61+ ``` java
62+ // metered route
63+ GET (" /metered" , new MeteredHandler (" HelloWorld" , routeContext - > routeContext. send(" Metered !!!" )));
64+ ```
65+
66+ ``` java
67+ GET (" /" , new RouteHandler () {
68+
69+ @Metered
70+ @Override
71+ public void handle (RouteContext routeContext ) {
72+ routeContext. send(" Hello World" );
73+ }
74+
75+ }). named(" HelloWorld" ); // <<< create a route with a name
76+
77+ ```
78+ in this case the metric name is the route name ("HelloWorld") because we have a named route and the metric name is missing for ` @Metered ` annotation.
79+
80+ ``` java
81+ GET (" /" , new MyHandler ());
82+
83+ public class MyHandler implements RouteHandler {
84+
85+ @Metered
86+ public void handle (RouteContext routeContext ) {
87+ routeContext. render(" hello" ); // render "hello" template
88+ }
89+
90+ }
91+ ```
92+ in this case the metric name is "MyHandler.handle" (route handler class name and "handle" - method name)
93+
94+ See below how to add a metric (time) in a controller
5995
6096``` java
6197public class ContactsController extends Controller {
@@ -74,12 +110,16 @@ public class ContactsController extends Controller {
74110
75111You may optionally enable JVM-level details reporting by setting * metrics.jvm.enabled=true* in your ` application.properties ` file.
76112
77- metrics.jvm.enabled = true
113+ ``` properties
114+ metrics.jvm.enabled = true
115+ ```
78116
79117#### Reporting Metrics via MBeans for VisualVM, JConsole, or JMX
80118
81- If you want to expose your metrics to VisualVM, JConsole, or JMX you must enable the MBeans reporter in your ` application.properties ` file.
119+ If you want to expose your metrics to ` VisualVM ` , ` JConsole ` , or ` JMX ` you must enable the MBeans reporter in your ` application.properties ` file.
82120
83- metrics.mbeans.enabled = true
121+ ``` properties
122+ metrics.mbeans.enabled = true
123+ ```
84124
85- You can view the collected metrics using VisualVM (with the MBeans plugin installed) or using JConsole.
125+ You can view the collected metrics using ` VisualVM ` (with the MBeans plugin installed) or using ` JConsole ` .
0 commit comments