Skip to content

Commit

Permalink
Increase BatchSpanProcessor queue and batch size
Browse files Browse the repository at this point in the history
To reduce the occurrence of dropped spans
  • Loading branch information
matt-richardson committed Nov 28, 2024
1 parent f120a98 commit 514e077
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.octopus.teamcity.opentelemetry.common;

import java.time.Duration;

public class PluginConstants {
private PluginConstants() {}
public static final String TRACER_INSTRUMENTATION_NAME = "octopus.teamcity.opentelemetry";
Expand All @@ -15,6 +17,9 @@ private PluginConstants() {}
public static final String PROPERTY_KEY_HONEYCOMB_APIKEY = "octopus.teamcity.opentelemetry.plugin.honeycomb.apikey";
public static final String PROPERTY_KEY_HONEYCOMB_METRICS_ENABLED = "octopus.teamcity.opentelemetry.plugin.honeycomb.metrics.enabled";

public static final int BATCH_SPAN_PROCESSOR_MAX_QUEUE_SIZE = 32768; // Default is 2048. Increasing it to limit dropped spans.
public static final Duration BATCH_SPAN_PROCESSOR_MAX_SCHEDULE_DELAY = Duration.ofSeconds(5); // Default is 5s. This is another lever we can tweak.
public static final int BATCH_SPAN_PROCESSOR_MAX_EXPORT_BATCH_SIZE = 8192; // Default is 512. Increasing it to limit dropped spans.

public static final String ATTRIBUTE_SERVICE_NAME = "service_name";
public static final String ATTRIBUTE_NAME = "name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private SpanProcessor buildGrpcSpanProcessor(Map<String, String> headers, String
LOG.debug("OTEL_PLUGIN: Opentelemetry export headers: " + LogMasker.mask(headers.toString()));
LOG.debug("OTEL_PLUGIN: Opentelemetry export endpoint: " + exporterEndpoint);

return BatchSpanProcessor.builder(spanExporter).build();
return BatchSpanProcessor.builder(spanExporter)
.setMaxQueueSize(BATCH_SPAN_PROCESSOR_MAX_QUEUE_SIZE)
.setScheduleDelay(BATCH_SPAN_PROCESSOR_MAX_SCHEDULE_DELAY)
.setMaxExportBatchSize(BATCH_SPAN_PROCESSOR_MAX_EXPORT_BATCH_SIZE)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ private SpanProcessor buildGrpcSpanProcessor(Map<String, String> headers, String
.build();

return BatchSpanProcessor.builder(spanExporter)
.setMaxQueueSize(32768) // Default is 2048. Increasing it to limit dropped spans.
.setScheduleDelay(Duration.ofSeconds(5)) // Default is 5s. This is another lever we can tweak.
.setMaxExportBatchSize(8192) // Default is 512. Increasing it to limit dropped spans.
.setMaxQueueSize(BATCH_SPAN_PROCESSOR_MAX_QUEUE_SIZE)
.setScheduleDelay(BATCH_SPAN_PROCESSOR_MAX_SCHEDULE_DELAY)
.setMaxExportBatchSize(BATCH_SPAN_PROCESSOR_MAX_EXPORT_BATCH_SIZE)
.setMeterProvider(meterProvider)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

import static com.octopus.teamcity.opentelemetry.common.PluginConstants.PROPERTY_KEY_ENDPOINT;
import static com.octopus.teamcity.opentelemetry.common.PluginConstants.*;

public class ZipKinOTELEndpointHandler implements IOTELEndpointHandler {
private final PluginDescriptor pluginDescriptor;
Expand Down Expand Up @@ -44,7 +44,11 @@ private SpanProcessor buildZipkinSpanProcessor(String exporterEndpoint) {
.setEndpoint(endpoint)
.build();

return BatchSpanProcessor.builder(zipkinExporter).build();
return BatchSpanProcessor.builder(zipkinExporter)
.setMaxQueueSize(BATCH_SPAN_PROCESSOR_MAX_QUEUE_SIZE)
.setScheduleDelay(BATCH_SPAN_PROCESSOR_MAX_SCHEDULE_DELAY)
.setMaxExportBatchSize(BATCH_SPAN_PROCESSOR_MAX_EXPORT_BATCH_SIZE)
.build();
}

@Override
Expand Down

0 comments on commit 514e077

Please sign in to comment.