From ad0e601b7024dac242160531c7885b5fd1eb2646 Mon Sep 17 00:00:00 2001 From: John Bley Date: Wed, 30 Oct 2024 08:40:13 -0400 Subject: [PATCH] Oct2024 updates (#313) * Update upstream otel-lambda to latest * Update splunk-otel-python to 1.21.0 and otel dependencies accordingly * Fix direct lambda call propagation --- nodejs/src/wrapper.ts | 18 ++++++++++++++++-- opentelemetry-lambda | 2 +- python/build-layer.sh | 10 +++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/nodejs/src/wrapper.ts b/nodejs/src/wrapper.ts index 9da507f..740cc6b 100644 --- a/nodejs/src/wrapper.ts +++ b/nodejs/src/wrapper.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { diag, DiagConsoleLogger, isSpanContextValid, TraceFlags } from "@opentelemetry/api"; +import { diag, DiagConsoleLogger, isSpanContextValid, propagation, context as otelContext, TraceFlags } from "@opentelemetry/api"; import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node'; import { getEnv } from '@opentelemetry/core'; import { detectResources, envDetector, processDetector } from '@opentelemetry/resources'; @@ -100,9 +100,23 @@ const responseHook: ResponseHook = (span, data) => { appendHeader(data.res.headers, 'Server-Timing', `traceparent;desc="00-${traceId}-${spanId}-${flags}"`); }; +const awsContextPropDisabled = typeof process.env['OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION'] === 'string' + && process.env['OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION'].toLowerCase() === 'true'; + +const extraLambdaConfig = awsContextPropDisabled ? + { + // enable trace chaining; FIXME should fix this in upstream? + eventContextExtractor: (event: any, context: any) => { + const eventContext = propagation.extract(otelContext.active(), context.clientContext?.Custom); + return eventContext; + }, + } : + { }; + const instrumentations = [ new AwsLambdaInstrumentation({ - responseHook + responseHook, + ...extraLambdaConfig, }), ...getInstrumentations(), ]; diff --git a/opentelemetry-lambda b/opentelemetry-lambda index f641b6b..cf82ba1 160000 --- a/opentelemetry-lambda +++ b/opentelemetry-lambda @@ -1 +1 @@ -Subproject commit f641b6b74892dba3e6ad29568b7e59dbea5e838c +Subproject commit cf82ba1ceed8dcb9076190b4a36ffe388f942029 diff --git a/python/build-layer.sh b/python/build-layer.sh index a41e74e..8b6e050 100755 --- a/python/build-layer.sh +++ b/python/build-layer.sh @@ -8,12 +8,12 @@ echo "Modify dependencies and script for Splunk integration" pushd "$OTEL_PYTHON_DIR" cd "$SOURCES_DIR" -sed -i 's/^opentelemetry-distro.*/splunk-opentelemetry[all]==1.20.0/g' requirements.txt -sed -i 's/^opentelemetry-exporter-otlp-proto-http.*/opentelemetry-exporter-otlp-proto-http==1.26.0/g' requirements.txt +sed -i 's/^opentelemetry-distro.*/splunk-opentelemetry[all]==1.21.0/g' requirements.txt +sed -i 's/^opentelemetry-exporter-otlp-proto-http.*/opentelemetry-exporter-otlp-proto-http==1.27.0/g' requirements.txt # Even if these regexes do nothing, leave these lines in to make later updates easier -sed -i 's/0.47b0/0.47b0/g' nodeps-requirements.txt -sed -i 's/0.47b0/0.47b0/g' requirements.txt -sed -i 's/1.26.0/1.26.0/g' requirements.txt +sed -i 's/0.48b0/0.48b0/g' nodeps-requirements.txt +sed -i 's/0.48b0/0.48b0/g' requirements.txt +sed -i 's/1.27.0/1.27.0/g' requirements.txt sed -i 's/^docker run --rm/docker run/g' ../../build.sh sed -i 's/opentelemetry-instrument/splunk-py-trace/g' otel-instrument # FIXME this recently broke and why aren't these a vendored part of pkg_resources anymore? perhaps we should remove the dependency on pkg_resources?