Metrics from Dropwizard

One of the most popular available libraries to help with metrics is simply called “Metrics”, and is available from

I was interested to try it out, looking at how useful it could be, and also how easy it would be to integrate into an application.

Getting Started

Metrics has a well-written Getting Started guide:

My Scenario

One of the applications our team is working on will need to process close to a million messages each day. One of the key things to measure and monitor is the duration of the processing time for those messages. We also want to be able to observe any trends upwards/downwards in the average processing time.

Collecting Metrics

Metrics provides a “Timer” which can do exactly this, exposing some statistics about the performance.

By following the code samples in the documentation, it was simple to embed the Timer in some existing code.

private MetricRegistry registry = new MetricRegistry();
private Timer responses = registry.timer(name(MyClass.class, "process"));
public void process() {
final Timer.Context context = responses.time();
try {
// do stuff
} finally {

Viewing Metrics

One of the features I like most about Metrics is the list of supported reporters. I first tried the Console reporter, then the HTTP reporter, but the one I am most likely to use is the JMX reporter.

Enabling this reporter required only a single additional Maven dependency and 2 lines of code.

After enabling the JMX reporter, I was able to inspect the metrics with VisualVM (with the MBeans plugin) and see what was going on in the application while under some test load.

The following VisualVM screenshot gives some idea of the data available.

Miscellaneous Other Features

At the risk of repeating the Getting Started Guide, the following list of features also look good.

  • Standardized “Health Check” reporting: you can register various health checks with metrics and expose these in a standard format
  • Integration with Graphite


Metrics seems a useful library, and simple to embed into an existing application, helped by their excellent documentation. I’m pretty sure I will be using it in future.

Like what you read? Give Kevin Grant a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.