Skip to content
Todd Fredrich edited this page Jul 3, 2013 · 3 revisions

Enables metrics on all routes in the service suite via the Yammer (Coda Hale) Metrics library. Metrics are available via JMX, but can be published to Graphite simply by configuring the Yammer (Coda Hale) Metrics publisher.

This plugin maintains metrics for the following:

  • currently active requests (counter)
  • all exceptions occurred (counter)
  • all times (timer, milliseconds/hours)
  • times by route (timer, milliseconds/hours)
  • exceptions by route (counter)
  • counters by return status (counter)

In addition, the overall response time is set in the response header, X-Response-Time, in milliseconds.

Note: Named routes are reported using their name. Unnamed routes are reported using the URL pattern. Usage

Usage of the Metrics Plugin is basically the same as the other plugins in this registry. Simply create a new plugin and register it with the RestExpress server, setting options as necessary, using method chaining if desired.

For example, to make metrics available via JMX:

RestExpress server = new RestExpress()...

new MetricsPlugin()
	.virtualMachineId("us-east-1a-beta1")	// optional. Unique name metrics are published under.
	.noLogging()				// optional. Turn off output logging.
	.logOutputFactory(logOutputFactory)	// optional. Set your own LogOutputFactory (SLF4J).
	.register(server);

Or to additionally publish metrics to Graphite:

RestExpress server = new RestExpress()...

new MetricsPlugin().register(server);

// Publish to graphite.example.com every minute...
GraphiteReporter.enable(1, TimeUnit.MINUTES, "graphite.example.com", 2003);