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.
Integrating the StatsDReporter from ReadyTalk
- add the bintray repository
- add ready talk dependency
- 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"
- 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.
./gradlew build
./gradlew install
add as a dependency:
dependencies {
compile('com.netuitive.statsd-reporter-example:1.0-SNAPSHOT')
}
metrics:
frequency: 1 minute
reporters:
- type: statsd-reporter-example
host: localhost
port: 8125
...