Skip to content

amirkibbar/banana

Repository files navigation

metrics-newrelic-reporter

a New Relic metrics reporter (see: http:https://metrics.dropwizard.io/3.1.0/, http:https://newrelic.com/)

Build Status

Download

Using the New Relic Metrics Reporter

Add the following to your gradle build:

    repositories {
        maven { url "http:https://dl.bintray.com/amirk/maven" }
    }
    
    dependencies {
        compile "ajk.metrics.newrelic:metrics-newrelic-reporter:0.0.3"
    }

Define the reporter:

    @Configuration
    public class MetricsConfig {
        @Bean
        public MetricRegistry metrics() {
            return new MetricRegistry();
        }
    
        @PostConstruct
        public void registerReporters() {
            NewRelicReporter newRelic = NewRelicReporter.forRegistry(metrics())
                    .build();
    
            newRelic.start(1, MINUTES);
        }
    }

This configuration will convert the rates into events per second, the durations into milliseconds and then report the metrics collected by the metric registry to New Relic every minute.

You need to setup your New Relic agent in the JVM running this reporter, if the agent is not setup then the report will simply not do anything.