Skip to content

Commit

Permalink
Used BatchSpansProcessor instead of SimpleSpansProcessor (#393)
Browse files Browse the repository at this point in the history
BatchSpansProcessor won't get blocked by the exporter.

Fixes #368
  • Loading branch information
RashmiRam committed May 16, 2020
1 parent 009cc6a commit 29a18bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private State() {}

public void setParentSpan(final Span parentSpan) {
final boolean result = parentSpanRef.compareAndSet(null, parentSpan);
if (!result) {
if (!result && parentSpanRef.get() != parentSpan) {
log.debug(
"Failed to set parent span because another parent span is already set {}: new: {}, old: {}",
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.opentelemetry.sdk.contrib.auto.config.SpanExporterFactory;
import io.opentelemetry.sdk.metrics.export.IntervalMetricReader;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
import io.opentelemetry.sdk.trace.export.BatchSpansProcessor;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.io.File;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -71,7 +71,9 @@ private static synchronized void installExportersFromJar(final String exporterJa
if (spanExporterFactory != null) {
final SpanExporter spanExporter = spanExporterFactory.fromConfig(config);
OpenTelemetrySdk.getTracerProvider()
.addSpanProcessor(SimpleSpansProcessor.create(spanExporter));
.addSpanProcessor(
BatchSpansProcessor.create(
spanExporter, BatchSpansProcessor.Config.loadFromDefaultSources()));
log.info("Installed span exporter: " + spanExporter.getClass().getName());
} else {
log.warn("No matching providers in jar " + exporterJar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ abstract class AbstractSmokeTest extends Specification {
processBuilder.environment().put("JAVA_HOME", System.getProperty("java.home"))
processBuilder.environment().put("DD_API_KEY", API_KEY)

// Setting configuration variables of batch span processor through env vars
// This config is to immediately flush a batch of 1 span with delay of 10ms
processBuilder.environment().put("OTEL_BSP_MAX_EXPORT_BATCH", "1")
processBuilder.environment().put("OTEL_BSP_SCHEDULE_DELAY", "10")

processBuilder.redirectErrorStream(true)
logfile = new File("${buildDirectory}/reports/testProcess.${this.getClass().getName()}.log")
processBuilder.redirectOutput(ProcessBuilder.Redirect.to(logfile))
Expand Down

0 comments on commit 29a18bd

Please sign in to comment.