DropWizard.io statsd-reporter-example
Example showing how to integrate a custom statsd-reporter into Dropwizard.io. via the SPI [ReporterFactory] (https://github.com/dropwizard/dropwizard/blob/master/dropwizard-metrics/src/main/java/io/dropwizard/metrics/ReporterFactory.java). This is the native way of plugging in new ScheduledReporter's'
As mentioned in ReporterFactory class we're going to:
- Create a class which implements
ReporterFactory
. - Annotate it with @JsonTypeName and give it a unique type name.
- Add a
src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory
file with your implementation's full class name to the class path.
StatsDReporter from ReadyTalk
Integrating theAdd metrics-statsd reporter as a dependency
- add the bintray repository
- add ready talk dependency
Adding the StatsDReporterFactory
- StatsDReporterFactory takes care of
- building and configuring the StatsDReporter instance we'll be using along with binding it to the MetricRegistry
- sets the name via the @JsonTypeName annotation, we named it "statsd-reporter-example"
Adding the io.dropwizard.metrics.ReporterFactory services file
- added
src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory
with our StatsDReporterFactory class defined as the ReporterFactory.
That's it, this can now be built and integrated into your dropwizard.io application. Check out this example to see how.
Build it
./gradlew build
Install it
./gradlew install
Use it in your own project
add as a dependency:
Gradle w/local install
dependencies {
compile('com.netuitive.statsd-reporter-example:1.0-SNAPSHOT')
}
Update your dropwizard.io config.yml
metrics:
frequency: 1 minute
reporters:
- type: statsd-reporter-example
host: localhost
port: 8125
Using bintray
...