Add dependency

Add the following dependency to the project.


Maven tile

When using maven add the following maven tile into the build / plugins section. This plugin performs build time enhancement of @Timed methods.

      <!-- other tiles ... -->

Gradle plugin

When using Gradle add the following plugin (TODO).

Register JVM metrics

Via MetricManager.jvmMetrics() specify if we want:

  • Standard JVM metrics (GC, Threads, Memory)
  • CGroup metrics
  • Logback or Log4J counters for errors and warnings

Below is typical configuration code that additionally specifies a reporter to report metrics to a local CSV file every 10 seconds.

class Configuration {

  MetricReportManager metrics() {


    // simple csv reporter
    MetricReportConfig config = new MetricReportConfig();
    return new MetricReportManager(config);

Add @Timed

Add @Timed to classes that we want methods to be timed. By default all public methods will have timing added to them.

public class IngestQueueConsumer {
  • Add @Timed on additional private methods that we want timing on
  • Add @NotTimed on public methods that we do not want timing on

Note that DInject controllers automatically have timing added.