Skip to content
Implementation of a DropWizard metrics Reporter that sends data as dimensional metrics to New Relic
Java Kotlin Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper Initial commit Aug 9, 2019
.gitignore release version 0.2.1 Sep 13, 2019 Initial commit Aug 9, 2019 release version 0.2.1 Sep 13, 2019
azure-pipelines-publish.yml Change publishing. Use latest snapshot of telemetry. Rev version. Aug 20, 2019
azure-pipelines.yml Set up CI with Azure Pipelines Aug 13, 2019
build.gradle.kts update telemetry version Sep 10, 2019 back to the snapshot Sep 13, 2019
gradlew Initial commit Aug 9, 2019
gradlew.bat Initial commit Aug 9, 2019 Initial commit Aug 9, 2019

New Relic Dropwizard Reporter

A Dropwizard metrics reporter for sending dimensional metrics to New Relic using the New Relic Java Telemetry SDK. For the juicy details on how Dropwizard metrics are mapped to New Relic dimensional metrics, please visit the exporter specs documentation repo.

How To Use




or if you're using kotlin build gradle...



If you do not want to depend on okhttp, you can remove the dependency on telemetry-http-okhttp, but you will need to construct a MetricBatchSender instance using its builder and provide your own implementation of the com.newrelic.telemetry.http.HttpPoster interface.

MetricBatchSender sender = MetricBatchSender.builder().httpPoster(<your implementation>);

Note: to use the sample code below, you will need the telemetry-http-okhttp library mentioned above. It provides implementations communicating via HTTP using the okhttp libraries, respectively.

Start The Reporter

Early in the lifecycle of your application, you will want to create and start a NewRelicReporter.

The YOUR_SECRET_API_KEY is referring to your New Relic Event API insert key. For more information and how to obtain a key, visit our docs.

MetricRegistry metricRegistry = new MetricRegistry(); // If you're already using dropwizard-metrics you may already have one of these.
String apiKey = "<YOUR_SECRET_API_KEY>";
MetricBatchSender metricBatchSender = SimpleMetricBatchSender.builder(apiKey).build();

Attributes commonAttributes = new Attributes()
            .put("host", InetAddress.getLocalHost().getHostName())
            .put("appName", "Your Application Name Here")
            .put("other", "any other common attributes you wish");
NewRelicReporter reporter =, metricBatchSender)
reporter.start(15, TimeUnit.SECONDS);

Dropwizard Integration

If you are using the actual Dropwizard REST framework, you can get a reference to the MetricRegistry from the Dropwizard Environment in order to register your reporter.
It might look something like this:

public class MyApplication extends Application<MyConfig> {

    public void run(MyConfig configuration, Environment environment) {
        MetricRegistry registry = environment.metrics();
        MetricBatchSender metricBatchSender = buildMetricBatchSender(); // see above for more complete example
        NewRelicReporter reporter =, metricBatchSender)
        reporter.start(15, TimeUnit.SECONDS);



CI builds are run on Azure Pipelines: Build Status The project uses gradle 5 for building, and the gradle wrapper is provided.

To compile, run the tests and build the jars:

$ ./gradlew build

You can’t perform that action at this time.