diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index d6fbb6d7e..de341dc96 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -22,6 +22,7 @@ import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.util.EC2MetadataUtils; import com.codahale.metrics.SharedMetricRegistries; import com.codahale.metrics.jdbi3.strategies.DefaultNameStrategy; import com.fasterxml.jackson.annotation.JsonAutoDetect; @@ -252,6 +253,7 @@ public class WhisperServerService extends Application tags = null; + + @Valid + @JsonProperty + private DynamicTagsCallbackFactory dynamicTagsCallback = null; + + @JsonProperty + private String prefix = null; + + @Valid + @NotNull + @JsonProperty + private EnumSet expansions = DatadogReporter.Expansion.ALL; + + @Valid + @NotNull + @JsonProperty + private MetricNameFormatterFactory metricNameFormatter = new DefaultMetricNameFormatterFactory(); + + @Valid + @NotNull + @JsonProperty + private AbstractTransportFactory transport = null; + + public ScheduledReporter build(MetricRegistry registry) { + return DatadogReporter.forRegistry(registry) + .withTransport(transport.build()) + .withHost(EC2MetadataUtils.getInstanceId()) + .withTags(tags) + .withPrefix(prefix) + .withExpansions(expansions) + .withMetricNameFormatter(metricNameFormatter.build()) + .withDynamicTagCallback(dynamicTagsCallback != null ? dynamicTagsCallback.build() : null) + .filter(getFilter()) + .convertDurationsTo(getDurationUnit()) + .convertRatesTo(getRateUnit()) + .build(); + } +} diff --git a/service/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory b/service/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory index bdc070f96..be127b6fd 100644 --- a/service/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory +++ b/service/src/main/resources/META-INF/services/io.dropwizard.metrics.ReporterFactory @@ -1 +1,2 @@ -org.whispersystems.textsecuregcm.metrics.JsonMetricsReporterFactory \ No newline at end of file +org.whispersystems.textsecuregcm.metrics.JsonMetricsReporterFactory +org.whispersystems.textsecuregcm.metrics.SignalDatadogReporterFactory