Add host and service tags

This commit is contained in:
Ehren Kret 2021-05-10 17:21:54 -05:00
parent 03a531e1b0
commit 670b69df24
3 changed files with 23 additions and 2 deletions

View File

@ -1,3 +1,5 @@
environment: # value
twilio: # Twilio gateway configuration
accountId:
accountToken:

View File

@ -12,6 +12,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.whispersystems.textsecuregcm.configuration.AccountDatabaseCrawlerConfiguration;
import org.whispersystems.textsecuregcm.configuration.AccountsDatabaseConfiguration;
@ -51,6 +52,10 @@ import org.whispersystems.websocket.configuration.WebSocketConfiguration;
/** @noinspection MismatchedQueryAndUpdateOfCollection, WeakerAccess */
public class WhisperServerConfiguration extends Configuration {
@NotEmpty
@JsonProperty
private String environment;
@NotNull
@Valid
@JsonProperty
@ -258,6 +263,10 @@ public class WhisperServerConfiguration extends Configuration {
private Map<String, String> transparentDataIndex = new HashMap<>();
public String getEnvironment() {
return environment;
}
public RecaptchaConfiguration getRecaptchaConfiguration() {
return recaptcha;
}

View File

@ -43,6 +43,8 @@ import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.wavefront.WavefrontConfig;
import io.micrometer.wavefront.WavefrontMeterRegistry;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.http.HttpClient;
import java.time.Duration;
import java.util.ArrayList;
@ -65,6 +67,7 @@ import org.jdbi.v3.core.Jdbi;
import org.signal.zkgroup.ServerSecretParams;
import org.signal.zkgroup.auth.ServerZkAuthOperations;
import org.signal.zkgroup.profiles.ServerZkProfileOperations;
import org.slf4j.MDC;
import org.whispersystems.dispatch.DispatchManager;
import org.whispersystems.textsecuregcm.auth.AccountAuthenticator;
import org.whispersystems.textsecuregcm.auth.CertificateGenerator;
@ -226,8 +229,15 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
@Override
public void run(WhisperServerConfiguration config, Environment environment)
throws Exception
{
throws Exception {
try {
MDC.put("host", InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
MDC.put("host", "unknown");
}
MDC.put("service", "chat");
MDC.put("ddsource", "logstash");
MDC.put("ddtags", "env:" + config.getEnvironment());
SharedMetricRegistries.add(Constants.METRICS_NAME, environment.metrics());
final WavefrontConfig wavefrontConfig = new WavefrontConfig() {