Skip to content

Commit 93e29d3

Browse files
committed
Support Trace Context extraction from Lambda Context object, and respect user-configured OTEL_PROPAGATORS (#1191)
*Issue #, if available:* - In latest `com.amazonaws:aws-lambda-java-core:1.4.0`, Lambda Context has a new `lambdaContext.getXrayTraceId()` method. We need to use this over SystemProperty/EnvVar to support multi-concurrency in Lambda. *Description of changes:* - respect OTEL_PROPAGATORS Env Var priority - Priority logic BEFORE: - Create `carrierA` to contain headers from Lambda request http headers and the custom client context - get X-Ray Trace ID from (in order or priority) SystemProperty or EnvVar, add it to new `carrierB` - Use Global Propagator to extract trace context from `carrierB` (trace extraction only works if xray propagator is configured) - If above trace extraction results in a context that is not valid&sampled, try again with Global Propagator using `carrierA` - Priority logic AFTER: - Create `carrierA` to contain headers from Lambda request http headers and the custom client context - get X-Ray Trace ID from (in order or priority) Lambda Context, SystemProperty, or EnvVar, add it to `carrierA` (will overwrite x-ray header value if present from Lambda request http headers). - Use Global Propagator to extract trace context from `carrierA` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 83edc98 commit 93e29d3

File tree

3 files changed

+380
-53
lines changed

3 files changed

+380
-53
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
> **Note:** This CHANGELOG was created starting after version 2.11.5. Earlier changes are not documented here.
6+
7+
For any change that affects end users of this package, please add an entry under the **Unreleased** section. Briefly summarize the change and provide the link to the PR. Example:
8+
9+
- add SigV4 authentication for HTTP exporter
10+
([#1019](https://github.com/aws-observability/aws-otel-java-instrumentation/pull/1019))
11+
12+
If your change does not need a CHANGELOG entry, add the "skip changelog" label to your PR.
13+
14+
## Unreleased
15+
16+
### Enhancements
17+
18+
- Support X-Ray Trace Id extraction from Lambda Context object, and respect user-configured OTEL_PROPAGATORS in AWS Lamdba instrumentation
19+
([#1191](https://github.com/aws-observability/aws-otel-java-instrumentation/pull/1191))

lambda-layer/otel-instrument

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
export OTEL_INSTRUMENTATION_AWS_SDK_EXPERIMENTAL_SPAN_ATTRIBUTES=true
44

5-
export OTEL_PROPAGATORS="${OTEL_PROPAGATORS:-baggage,xray,tracecontext}"
5+
export OTEL_PROPAGATORS="${OTEL_PROPAGATORS:-baggage,tracecontext,xray}"
66

77
export OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-${AWS_LAMBDA_FUNCTION_NAME}}
88

0 commit comments

Comments
 (0)