Submit Micrometer metrics via dogstatsd instead of the Datadog API
This commit is contained in:
parent
1f8e4713ef
commit
8103a22026
|
@ -224,10 +224,6 @@ cdn:
|
||||||
bucket: cdn # S3 Bucket name
|
bucket: cdn # S3 Bucket name
|
||||||
region: us-west-2 # AWS region
|
region: us-west-2 # AWS region
|
||||||
|
|
||||||
datadog:
|
|
||||||
apiKey: secret://datadog.apiKey
|
|
||||||
environment: dev
|
|
||||||
|
|
||||||
unidentifiedDelivery:
|
unidentifiedDelivery:
|
||||||
certificate: secret://unidentifiedDelivery.certificate
|
certificate: secret://unidentifiedDelivery.certificate
|
||||||
privateKey: secret://unidentifiedDelivery.privateKey
|
privateKey: secret://unidentifiedDelivery.privateKey
|
||||||
|
|
|
@ -255,7 +255,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.micrometer</groupId>
|
<groupId>io.micrometer</groupId>
|
||||||
<artifactId>micrometer-registry-datadog</artifactId>
|
<artifactId>micrometer-registry-statsd</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.coursera</groupId>
|
<groupId>org.coursera</groupId>
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.whispersystems.textsecuregcm.configuration.BraintreeConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.CdnConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.CdnConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.ClientReleaseConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.ClientReleaseConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.CommandStopListenerConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.CommandStopListenerConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DatadogConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DogstatsdConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DirectoryV2Configuration;
|
import org.whispersystems.textsecuregcm.configuration.DirectoryV2Configuration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbTables;
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbTables;
|
||||||
|
@ -106,7 +106,7 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Valid
|
@Valid
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private DatadogConfiguration datadog;
|
private DogstatsdConfiguration dogstatsd = new DogstatsdConfiguration();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Valid
|
@Valid
|
||||||
|
@ -416,8 +416,8 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
return cdn;
|
return cdn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatadogConfiguration getDatadogConfiguration() {
|
public DogstatsdConfiguration getDatadogConfiguration() {
|
||||||
return datadog;
|
return dogstatsd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnidentifiedDeliveryConfiguration getDeliveryCertificate() {
|
public UnidentifiedDeliveryConfiguration getDeliveryCertificate() {
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2013 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import io.micrometer.datadog.DatadogConfig;
|
|
||||||
import java.time.Duration;
|
|
||||||
import javax.validation.constraints.Min;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.secrets.SecretString;
|
|
||||||
|
|
||||||
public class DatadogConfiguration implements DatadogConfig {
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
@NotNull
|
|
||||||
private SecretString apiKey;
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
@NotNull
|
|
||||||
private Duration step = Duration.ofSeconds(10);
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
@NotBlank
|
|
||||||
private String environment;
|
|
||||||
|
|
||||||
@JsonProperty
|
|
||||||
@Min(1)
|
|
||||||
private int batchSize = 5_000;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String apiKey() {
|
|
||||||
return apiKey.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Duration step() {
|
|
||||||
return step;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEnvironment() {
|
|
||||||
return environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int batchSize() {
|
|
||||||
return batchSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String hostTag() {
|
|
||||||
return "host";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get(final String key) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Signal Messenger, LLC
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.whispersystems.textsecuregcm.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.micrometer.statsd.StatsdConfig;
|
||||||
|
import io.micrometer.statsd.StatsdFlavor;
|
||||||
|
import java.time.Duration;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
public class DogstatsdConfiguration implements StatsdConfig {
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
@NotNull
|
||||||
|
private Duration step = Duration.ofSeconds(10);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration step() {
|
||||||
|
return step;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatsdFlavor flavor() {
|
||||||
|
return StatsdFlavor.DATADOG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(final String key) {
|
||||||
|
// We have no Micrometer key/value pairs to report, so always return `null`
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,10 +14,9 @@ import io.micrometer.core.instrument.Metrics;
|
||||||
import io.micrometer.core.instrument.Tags;
|
import io.micrometer.core.instrument.Tags;
|
||||||
import io.micrometer.core.instrument.config.MeterFilter;
|
import io.micrometer.core.instrument.config.MeterFilter;
|
||||||
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
|
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
|
||||||
import io.micrometer.datadog.DatadogMeterRegistry;
|
import io.micrometer.statsd.StatsdMeterRegistry;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.WhisperServerVersion;
|
|
||||||
import org.whispersystems.textsecuregcm.util.Constants;
|
import org.whispersystems.textsecuregcm.util.Constants;
|
||||||
import org.whispersystems.textsecuregcm.util.HostnameUtil;
|
import org.whispersystems.textsecuregcm.util.HostnameUtil;
|
||||||
|
|
||||||
|
@ -45,17 +44,11 @@ public class MetricsUtil {
|
||||||
SharedMetricRegistries.add(Constants.METRICS_NAME, environment.metrics());
|
SharedMetricRegistries.add(Constants.METRICS_NAME, environment.metrics());
|
||||||
|
|
||||||
{
|
{
|
||||||
final DatadogMeterRegistry datadogMeterRegistry = new DatadogMeterRegistry(
|
final StatsdMeterRegistry dogstatsdMeterRegistry = new StatsdMeterRegistry(
|
||||||
config.getDatadogConfiguration(), io.micrometer.core.instrument.Clock.SYSTEM);
|
config.getDatadogConfiguration(), io.micrometer.core.instrument.Clock.SYSTEM);
|
||||||
|
|
||||||
datadogMeterRegistry.config().commonTags(
|
configureMeterFilters(dogstatsdMeterRegistry.config());
|
||||||
Tags.of(
|
Metrics.addRegistry(dogstatsdMeterRegistry);
|
||||||
"service", "chat",
|
|
||||||
"host", HostnameUtil.getLocalHostname(),
|
|
||||||
"version", WhisperServerVersion.getServerVersion(),
|
|
||||||
"env", config.getDatadogConfiguration().getEnvironment()));
|
|
||||||
configureMeterFilters(datadogMeterRegistry.config());
|
|
||||||
Metrics.addRegistry(datadogMeterRegistry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
environment.lifecycle().manage(new MicrometerRegistryManager(Metrics.globalRegistry));
|
environment.lifecycle().manage(new MicrometerRegistryManager(Metrics.globalRegistry));
|
||||||
|
|
Loading…
Reference in New Issue