Adding additional metrics to Dropwizard

dropwizard, java

Solution

Dropwizard's using the Metrics library for all of its metrics. Metric's getting started section has everything you need to start adding your own.

Problem

How do I go about adding custom metrics to the default stuff that Dropwizard provides on the admin port (8081)? I can't find anything in the documentation apart from adding health checks. I'd quite like to incorporate some stats retrieved from MongoDB, and would rather keep it with the admin resources on 8081 than create a custom metrics page on port 8080.

Original source