+ *
+ * | Name |
+ * Default |
+ * Description |
+ *
+ *
+ * | host |
+ * localhost |
+ * The hostname of the Statsd server to report to. |
+ *
+ *
+ * | port |
+ * 8080 |
+ * The port of the Statsd server to report to. |
+ *
+ *
+ * | prefix |
+ * None |
+ * The prefix for Metric key names to report to Statsd. |
+ *
+ *
+ */
+@JsonTypeName("statsd")
+public class StatsdReporterFactory extends BaseReporterFactory {
+ @NotEmpty
+ private String host = "localhost";
+
+ @Range(min = 0, max = 49151)
+ private int port = 8080;
+
+ @NotNull
+ private String prefix = "";
+
+ @JsonProperty
+ public String getHost() {
+ return host;
+ }
+
+ @JsonProperty
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ @JsonProperty
+ public int getPort() {
+ return port;
+ }
+
+ @JsonProperty
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ @JsonProperty
+ public String getPrefix() {
+ return prefix;
+ }
+
+ @JsonProperty
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ * Configures and builds a {@link com.codahale.metrics.ScheduledReporter} instance for the given registry.
+ *
+ * @param registry the metrics registry to report metrics from.
+ * @return a reporter configured for the given metrics registry.
+ */
+ @Override
+ public ScheduledReporter build(MetricRegistry registry) {
+ Statsd statsd = new Statsd(host, port);
+ return StatsdReporter.forRegistry(registry)
+ .prefixedWith(prefix)
+ .convertDurationsTo(getDurationUnit())
+ .convertRatesTo(getRateUnit())
+ .filter(getFilter())
+ .build(statsd);
+ }
+}
diff --git a/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory b/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory
new file mode 100644
index 0000000..f310f65
--- /dev/null
+++ b/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory
@@ -0,0 +1 @@
+com.bealetech.metrics.reporting.StatsdReporterFactory
\ No newline at end of file