Skip to content

Commit

Permalink
JSON metrics reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
moxie0 committed Mar 19, 2014
1 parent 5667476 commit aea3f29
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -9,7 +9,7 @@

<groupId>org.whispersystems.textsecure</groupId>
<artifactId>TextSecureServer</artifactId>
<version>0.7</version>
<version>0.8</version>

<dependencies>
<dependency>
Expand Down
Expand Up @@ -20,11 +20,11 @@
import com.yammer.dropwizard.config.Configuration;
import com.yammer.dropwizard.db.DatabaseConfiguration;
import org.whispersystems.textsecuregcm.configuration.ApnConfiguration;
import org.whispersystems.textsecuregcm.configuration.DataDogConfiguration;
import org.whispersystems.textsecuregcm.configuration.FederationConfiguration;
import org.whispersystems.textsecuregcm.configuration.GcmConfiguration;
import org.whispersystems.textsecuregcm.configuration.GraphiteConfiguration;
import org.whispersystems.textsecuregcm.configuration.MemcacheConfiguration;
import org.whispersystems.textsecuregcm.configuration.MetricsConfiguration;
import org.whispersystems.textsecuregcm.configuration.NexmoConfiguration;
import org.whispersystems.textsecuregcm.configuration.RateLimitsConfiguration;
import org.whispersystems.textsecuregcm.configuration.RedisConfiguration;
Expand Down Expand Up @@ -87,7 +87,7 @@ public class WhisperServerConfiguration extends Configuration {

@Valid
@JsonProperty
private DataDogConfiguration datadog = new DataDogConfiguration();
private MetricsConfiguration metrics = new MetricsConfiguration();

@Valid
@JsonProperty
Expand Down Expand Up @@ -141,7 +141,7 @@ public GraphiteConfiguration getGraphiteConfiguration() {
return graphite;
}

public DataDogConfiguration getDataDogConfiguration() {
return datadog;
public MetricsConfiguration getMetricsConfiguration() {
return metrics;
}
}
Expand Up @@ -24,6 +24,7 @@
import com.yammer.dropwizard.db.DatabaseConfiguration;
import com.yammer.dropwizard.jdbi.DBIFactory;
import com.yammer.dropwizard.migrations.MigrationsBundle;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Clock;
import com.yammer.metrics.core.MetricPredicate;
import com.yammer.metrics.reporting.DatadogReporter;
Expand All @@ -48,6 +49,7 @@
import org.whispersystems.textsecuregcm.limits.RateLimiters;
import org.whispersystems.textsecuregcm.mappers.IOExceptionMapper;
import org.whispersystems.textsecuregcm.mappers.RateLimitExceededExceptionMapper;
import org.whispersystems.textsecuregcm.metrics.JsonMetricsReporter;
import org.whispersystems.textsecuregcm.providers.MemcacheHealthCheck;
import org.whispersystems.textsecuregcm.providers.MemcachedClientFactory;
import org.whispersystems.textsecuregcm.providers.RedisClientFactory;
Expand Down Expand Up @@ -168,11 +170,11 @@ public void run(WhisperServerConfiguration config, Environment environment)
config.getGraphiteConfiguration().getPort());
}

if (config.getDataDogConfiguration().isEnabled()) {
new DatadogReporter.Builder().withApiKey(config.getDataDogConfiguration().getApiKey())
.withVmMetricsEnabled(true)
.build()
.start(15, TimeUnit.SECONDS);
if (config.getMetricsConfiguration().isEnabled()) {
new JsonMetricsReporter("textsecure", Metrics.defaultRegistry(),
config.getMetricsConfiguration().getToken(),
config.getMetricsConfiguration().getHost())
.start(60, TimeUnit.SECONDS);
}
}

Expand Down
@@ -0,0 +1,27 @@
package org.whispersystems.textsecuregcm.configuration;

import com.fasterxml.jackson.annotation.JsonProperty;

public class MetricsConfiguration {

@JsonProperty
private String token;

@JsonProperty
private String host;

@JsonProperty
private boolean enabled = false;

public String getHost() {
return host;
}

public String getToken() {
return token;
}

public boolean isEnabled() {
return enabled && token != null && host != null;
}
}

1 comment on commit aea3f29

@WhisperBTC
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! BitHub has sent payment of $42.13USD for this commit.

Please sign in to comment.