diff --git a/aws-distro-opentelemetry-node-autoinstrumentation/src/aws-opentelemetry-configurator.ts b/aws-distro-opentelemetry-node-autoinstrumentation/src/aws-opentelemetry-configurator.ts index 52281a66..654a85a7 100644 --- a/aws-distro-opentelemetry-node-autoinstrumentation/src/aws-opentelemetry-configurator.ts +++ b/aws-distro-opentelemetry-node-autoinstrumentation/src/aws-opentelemetry-configurator.ts @@ -256,14 +256,13 @@ export class AwsOpentelemetryConfigurator { // Register BatchUnsampledSpanProcessor to export unsampled traces in Lambda // when Application Signals enabled - if (isLambdaEnvironment()) { + if (isLambdaEnvironment() && !hasCustomOtlpTraceEndpoint()) { + const udpSpanExporter = new OTLPUdpSpanExporter(getXrayDaemonEndpoint(), FORMAT_OTEL_UNSAMPLED_TRACES_BINARY_PREFIX); + const configuredExporter = AwsMetricAttributesSpanExporterBuilder.create(udpSpanExporter, resource).build(); spanProcessors.push( - new AwsBatchUnsampledSpanProcessor( - new OTLPUdpSpanExporter(getXrayDaemonEndpoint(), FORMAT_OTEL_UNSAMPLED_TRACES_BINARY_PREFIX), - { - maxExportBatchSize: getSpanExportBatchSize(), - } - ) + new AwsBatchUnsampledSpanProcessor(configuredExporter, { + maxExportBatchSize: getSpanExportBatchSize(), + }) ); diag.info('Enabled batch unsampled span processor for Lambda environment.'); }