Skip to content

Commit b216701

Browse files
committed
add comment
1 parent 99dace1 commit b216701

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/src/patches/instrumentation-patch.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,9 @@ export function applyInstrumentationPatches(instrumentations: Instrumentation[])
106106

107107
/*
108108
* This function `customExtractor` is used to extract SpanContext for AWS Lambda functions.
109-
* It first attempts to extract the trace context from the Lambda Handler Context object (_handlerContext.xRayTraceId)
110-
* If above approach fails, attempt to extract the trace context from the AWS X-Ray header, which is stored in the Lambda environment variables.
111-
* If a valid span context is extracted from the environment, it uses this as the parent context for the function's tracing.
112-
* If the X-Ray header is missing or invalid, it falls back to extracting trace context from the Lambda handler's event headers.
113-
* If neither approach succeeds, it defaults to using the root Otel context, ensuring the function is still instrumented for tracing.
109+
* It extracts the X-Ray trace ID from the Lambda environment variable (_X_AMZN_TRACE_ID) and adds it to the event headers.
110+
* It then uses OpenTelemetry propagation to extract trace context from both the event headers and Lambda context.
111+
* If a valid span context is extracted, it returns that context; otherwise, it returns the root context.
114112
*/
115113
const lambdaContextXrayTraceIdKey = 'xRayTraceId';
116114
export const customExtractor = (event: any, _handlerContext: Context): OtelContext => {

0 commit comments

Comments
 (0)