Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mockito.version>3.7.7</mockito.version>
<opencensus.version>0.28.3</opencensus.version>
</properties>

<profiles>
Expand Down Expand Up @@ -332,6 +333,28 @@
<artifactId>jgroups-raft</artifactId>
<version>1.0.0.Final</version>
</dependency>
<!-- OpenCensus used for pushing metrics to stackdriver -->
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-contrib-dropwizard</artifactId>
<version>${opencensus.version}</version>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-api</artifactId>
<version>${opencensus.version}</version>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-impl</artifactId>
<version>${opencensus.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-exporter-stats-stackdriver</artifactId>
<version>${opencensus.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/zendesk/maxwell/MaxwellConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/zendesk/maxwell/monitoring/MaxwellMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;

Expand All @@ -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<Reporter> reporters = new ArrayList<>();
Expand Down Expand Up @@ -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));
}
Expand Down