Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used BatchSpansProcessor instead of SimpleSpansProcessor #393

Merged
merged 12 commits into from
May 16, 2020
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 @@ -69,7 +69,7 @@ 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())); // Loads configuration for SpansProcessor from env vars if exists.
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")
Copy link
Member

Choose a reason for hiding this comment

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

I like this solution a lot. Much cleaner than anything I had suggested.

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