diff --git a/common/src/main/java/com/octopus/teamcity/opentelemetry/common/PluginConstants.java b/common/src/main/java/com/octopus/teamcity/opentelemetry/common/PluginConstants.java index 4aae058..d9fc324 100644 --- a/common/src/main/java/com/octopus/teamcity/opentelemetry/common/PluginConstants.java +++ b/common/src/main/java/com/octopus/teamcity/opentelemetry/common/PluginConstants.java @@ -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"; @@ -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"; diff --git a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/custom/CustomOTELEndpointHandler.java b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/custom/CustomOTELEndpointHandler.java index ebdeed8..f68711f 100644 --- a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/custom/CustomOTELEndpointHandler.java +++ b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/custom/CustomOTELEndpointHandler.java @@ -81,6 +81,10 @@ private SpanProcessor buildGrpcSpanProcessor(Map 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(); } } diff --git a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java index 9dc77b1..2651980 100644 --- a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java +++ b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java @@ -94,7 +94,12 @@ private SpanProcessor buildGrpcSpanProcessor(Map 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 diff --git a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/zipkin/ZipKinOTELEndpointHandler.java b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/zipkin/ZipKinOTELEndpointHandler.java index 316cd36..f9702bf 100644 --- a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/zipkin/ZipKinOTELEndpointHandler.java +++ b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/zipkin/ZipKinOTELEndpointHandler.java @@ -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; @@ -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