diff --git a/service/pom.xml b/service/pom.xml index 0dfbeaa5af65f356e3bd506184f1fbb897932ed4..23342928238db8a625271fe2062c1471c2a5b0ee 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -222,6 +222,10 @@ <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-wavefront</artifactId> </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-registry-datadog</artifactId> + </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java index 428838940e914bfdfa15ba909d6dd97080611c07..640004e7a6b538b61c283992d2c2b9ad92cc52db 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java @@ -21,6 +21,7 @@ import org.whispersystems.textsecuregcm.configuration.AppConfigConfiguration; import org.whispersystems.textsecuregcm.configuration.AwsAttachmentsConfiguration; import org.whispersystems.textsecuregcm.configuration.CdnConfiguration; import org.whispersystems.textsecuregcm.configuration.DatabaseConfiguration; +import org.whispersystems.textsecuregcm.configuration.DatadogConfiguration; import org.whispersystems.textsecuregcm.configuration.DirectoryConfiguration; import org.whispersystems.textsecuregcm.configuration.DonationConfiguration; import org.whispersystems.textsecuregcm.configuration.DynamoDbConfiguration; @@ -29,7 +30,7 @@ import org.whispersystems.textsecuregcm.configuration.GcpAttachmentsConfiguratio import org.whispersystems.textsecuregcm.configuration.MaxDeviceConfiguration; import org.whispersystems.textsecuregcm.configuration.MessageCacheConfiguration; import org.whispersystems.textsecuregcm.configuration.MessageDynamoDbConfiguration; -import org.whispersystems.textsecuregcm.configuration.MicrometerConfiguration; +import org.whispersystems.textsecuregcm.configuration.WavefrontConfiguration; import org.whispersystems.textsecuregcm.configuration.PaymentsServiceConfiguration; import org.whispersystems.textsecuregcm.configuration.PushConfiguration; import org.whispersystems.textsecuregcm.configuration.RateLimitsConfiguration; @@ -79,7 +80,12 @@ public class WhisperServerConfiguration extends Configuration { @NotNull @Valid @JsonProperty - private MicrometerConfiguration micrometer; + private WavefrontConfiguration wavefront; + + @NotNull + @Valid + @JsonProperty + private DatadogConfiguration datadog; @NotNull @Valid @@ -393,8 +399,12 @@ public class WhisperServerConfiguration extends Configuration { return cdn; } - public MicrometerConfiguration getMicrometerConfiguration() { - return micrometer; + public WavefrontConfiguration getWavefrontConfiguration() { + return wavefront; + } + + public DatadogConfiguration getDatadogConfiguration() { + return datadog; } public UnidentifiedDeliveryConfiguration getDeliveryCertificate() { diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index 6ce0718e06004fa271bbd1b17b45bea6baef36f2..4d47e029f1cf1a5b75fe430ed5e811275a88d0a0 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -40,7 +40,10 @@ import io.dropwizard.setup.Environment; import io.lettuce.core.resource.ClientResources; import io.micrometer.core.instrument.Clock; import io.micrometer.core.instrument.Metrics; +import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.core.instrument.distribution.DistributionStatisticConfig; +import io.micrometer.datadog.DatadogConfig; +import io.micrometer.datadog.DatadogMeterRegistry; import io.micrometer.wavefront.WavefrontConfig; import io.micrometer.wavefront.WavefrontMeterRegistry; import java.net.http.HttpClient; @@ -251,12 +254,12 @@ public class WhisperServerService extends Application<WhisperServerConfiguration @Override public String uri() { - return config.getMicrometerConfiguration().getUri(); + return config.getWavefrontConfiguration().getUri(); } @Override public int batchSize() { - return config.getMicrometerConfiguration().getBatchSize(); + return config.getWavefrontConfiguration().getBatchSize(); } }; @@ -270,6 +273,22 @@ public class WhisperServerService extends Application<WhisperServerConfiguration } }); + { + final DatadogMeterRegistry datadogMeterRegistry = new DatadogMeterRegistry(new DatadogConfig() { + @Override + public String get(final String key) { + return null; + } + + @Override + public String apiKey() { + return config.getDatadogConfiguration().getApiKey(); + } + }, Clock.SYSTEM); + + Metrics.addRegistry(datadogMeterRegistry); + } + environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); environment.getObjectMapper().setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); environment.getObjectMapper().setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/DatadogConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/DatadogConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..e195682d09bb85add0d6351c6362c6a6041719e2 --- /dev/null +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/DatadogConfiguration.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013-2021 Signal Messenger, LLC + * SPDX-License-Identifier: AGPL-3.0-only + */ + +package org.whispersystems.textsecuregcm.configuration; + +import com.fasterxml.jackson.annotation.JsonProperty; +import javax.validation.constraints.NotBlank; + +public class DatadogConfiguration { + + @JsonProperty + @NotBlank + private String apiKey; + + public String getApiKey() { + return apiKey; + } +} diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/MicrometerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/WavefrontConfiguration.java similarity index 92% rename from service/src/main/java/org/whispersystems/textsecuregcm/configuration/MicrometerConfiguration.java rename to service/src/main/java/org/whispersystems/textsecuregcm/configuration/WavefrontConfiguration.java index f9d9fd3d4464cb078949981a904f23ba31d0765c..1c32d9f7496c536d061a3760b43921b98363f55c 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/MicrometerConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/WavefrontConfiguration.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import javax.validation.constraints.Positive; -public class MicrometerConfiguration { +public class WavefrontConfiguration { @JsonProperty private String uri;