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

Increase throughput of the BatchSpanProcessor #340

Merged
merged 2 commits into from
Nov 28, 2024
Merged
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
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 @@ -94,7 +94,12 @@ private SpanProcessor buildGrpcSpanProcessor(Map<String, String> headers, String
.setMeterProvider(meterProvider)
.build();

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)
.setMeterProvider(meterProvider)
.build();
}

@Override
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