diff --git a/pom.xml b/pom.xml
index c7ff29893..d71bd6e80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,7 @@
UTF-8
3.7.7
+ 0.28.3
@@ -332,6 +333,28 @@
jgroups-raft
1.0.0.Final
+
+
+ io.opencensus
+ opencensus-contrib-dropwizard
+ ${opencensus.version}
+
+
+ io.opencensus
+ opencensus-api
+ ${opencensus.version}
+
+
+ io.opencensus
+ opencensus-impl
+ ${opencensus.version}
+ runtime
+
+
+ io.opencensus
+ opencensus-exporter-stats-stackdriver
+ ${opencensus.version}
+
diff --git a/src/main/java/com/zendesk/maxwell/MaxwellConfig.java b/src/main/java/com/zendesk/maxwell/MaxwellConfig.java
index 00be4008d..5a093d961 100644
--- a/src/main/java/com/zendesk/maxwell/MaxwellConfig.java
+++ b/src/main/java/com/zendesk/maxwell/MaxwellConfig.java
@@ -460,7 +460,7 @@ protected MaxwellOptionParser buildOptionParser() {
parser.section("metrics");
parser.accepts( "metrics_prefix", "the prefix maxwell will apply to all metrics" ).withRequiredArg();
- parser.accepts( "metrics_type", "how maxwell metrics will be reported, at least one of slf4j|jmx|http|datadog" ).withRequiredArg();
+ parser.accepts( "metrics_type", "how maxwell metrics will be reported, at least one of slf4j|jmx|http|datadog|stackdriver" ).withRequiredArg();
parser.accepts( "metrics_slf4j_interval", "the frequency metrics are emitted to the log, in seconds, when slf4j reporting is configured" ).withRequiredArg();
parser.accepts( "metrics_age_slo", "the threshold in seconds for message age service level objective" ).withRequiredArg().ofType(Integer.class);
parser.accepts( "http_port", "the port the server will bind to when http reporting is configured" ).withRequiredArg().ofType(Integer.class);
diff --git a/src/main/java/com/zendesk/maxwell/monitoring/MaxwellMetrics.java b/src/main/java/com/zendesk/maxwell/monitoring/MaxwellMetrics.java
index 8d6675fcf..adf8c7099 100644
--- a/src/main/java/com/zendesk/maxwell/monitoring/MaxwellMetrics.java
+++ b/src/main/java/com/zendesk/maxwell/monitoring/MaxwellMetrics.java
@@ -12,6 +12,8 @@
import com.zendesk.maxwell.MaxwellContext;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.dropwizard.DropwizardExports;
+import io.opencensus.exporter.stats.stackdriver.StackdriverStatsExporter;
+
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,6 +22,7 @@
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.concurrent.TimeUnit;
+import java.util.Collections;
import static com.viafoura.metrics.datadog.DatadogReporter.Expansion.*;
@@ -29,6 +32,7 @@ public class MaxwellMetrics implements Metrics {
static final String reportingTypeJmx = "jmx";
static final String reportingTypeHttp = "http";
static final String reportingTypeDataDog = "datadog";
+ static final String reportingTypeStackdriver = "stackdriver";
private static final Logger LOGGER = LoggerFactory.getLogger(MaxwellMetrics.class);
private final ArrayList reporters = new ArrayList<>();
@@ -118,6 +122,20 @@ private void setup(MaxwellConfig config) {
LOGGER.info("Datadog reporting enabled");
}
+ if (config.metricsReportingType.contains(reportingTypeStackdriver)) {
+ io.opencensus.metrics.Metrics.getExportComponent().getMetricProducerManager().add(
+ new io.opencensus.contrib.dropwizard.DropWizardMetrics(
+ Collections.singletonList(this.registry)));
+
+ try {
+ StackdriverStatsExporter.createAndRegister();
+ } catch (java.io.IOException e) {
+ LOGGER.error("Maxwell encountered an error in creating the stackdriver exporter.", e);
+ }
+
+ LOGGER.info("Stackdriver metrics reporter enabled");
+ }
+
if (config.metricsReportingType.contains(reportingTypeHttp)) {
CollectorRegistry.defaultRegistry.register(new DropwizardExports(this.registry));
}