Skip to content

Commit

Permalink
Batch export requests
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Feb 10, 2022
1 parent d9d8e1c commit 1d47a04
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public OpenTelemetrySdk getOpenTelemetrySdk() {

@Override
public List<SpanData> getExportedSpans() {
openTelemetry.getSdkTracerProvider().forceFlush().join(10, TimeUnit.SECONDS);
return testSpanExporter.getFinishedSpanItems();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.opentelemetry.sdk.metrics.export.MetricReader;
import io.opentelemetry.sdk.metrics.export.MetricReaderFactory;
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
import java.time.Duration;
import javax.annotation.Nullable;

Expand All @@ -28,7 +28,9 @@ public class AgentTestingCustomizer implements AutoConfigurationCustomizerProvid

static final AgentTestingSpanProcessor spanProcessor =
new AgentTestingSpanProcessor(
SimpleSpanProcessor.create(AgentTestingExporterFactory.spanExporter));
BatchSpanProcessor.builder(AgentTestingExporterFactory.spanExporter)
.setScheduleDelay(Duration.ofMillis(200))
.build());

static void reset() {
spanProcessor.forceFlushCalled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class AgentTestingExporterFactory {
static final OtlpInMemoryLogExporter logExporter = new OtlpInMemoryLogExporter(collector);

public static List<byte[]> getSpanExportRequests() {
AgentTestingCustomizer.spanProcessor.forceFlush().join(10, TimeUnit.SECONDS);
return collector.getTraceExportRequests();
}

Expand All @@ -28,6 +29,7 @@ public static List<byte[]> getMetricExportRequests() {
}

public static List<byte[]> getLogExportRequests() {
AgentTestingLogsCustomizer.logProcessor.forceFlush().join(10, TimeUnit.SECONDS);
return collector.getLogsExportRequests();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
import io.opentelemetry.sdk.logs.LogProcessor;
import io.opentelemetry.sdk.logs.SdkLogEmitterProvider;
import io.opentelemetry.sdk.logs.export.SimpleLogProcessor;
import io.opentelemetry.sdk.logs.export.BatchLogProcessor;
import java.time.Duration;

@AutoService(AgentListener.class)
public class AgentTestingLogsCustomizer implements AgentListener {

static final LogProcessor logProcessor =
SimpleLogProcessor.create(AgentTestingExporterFactory.logExporter);
BatchLogProcessor.builder(AgentTestingExporterFactory.logExporter)
.setScheduleDelay(Duration.ofMillis(200))
.build();

@Override
public void beforeAgent(
Expand Down

0 comments on commit 1d47a04

Please sign in to comment.