Skip to content

Conversation

@jj22ee
Copy link
Contributor

@jj22ee jj22ee commented Sep 16, 2025

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.

@jj22ee jj22ee requested a review from a team as a code owner September 16, 2025 19:07
@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.07%. Comparing base (09e6487) to head (a60b0b3).
⚠️ Report is 500 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@              Coverage Diff              @@
##               main    #1191       +/-   ##
=============================================
- Coverage     85.71%   67.07%   -18.64%     
- Complexity       19      525      +506     
=============================================
  Files             3       54       +51     
  Lines            49     2694     +2645     
  Branches          5      376      +371     
=============================================
+ Hits             42     1807     +1765     
- Misses            3      750      +747     
- Partials          4      137      +133     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

wangzlei
wangzlei previously approved these changes Sep 17, 2025
Copy link
Contributor

@wangzlei wangzlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jj22ee jj22ee enabled auto-merge (squash) September 17, 2025 23:37
@jj22ee jj22ee merged commit 551937d into aws-observability:main Sep 20, 2025
6 checks passed
jj22ee added a commit that referenced this pull request Sep 24, 2025
…Muzzle Check (#1218)

*Issue #, if available:*
-
https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/17954879038/job/51066448865

AWS Lambda Environment may or may not have the `getXrayTraceId` method
in Lambda Context (from Lambda Core dependency). This will cause OTel's
Muzzle Check to disable the AWS Lambda Instrumentation in the event that
it isn't present, causing no Lambda Function Handler Span to appear

Fix of previous PR:
#1191

*Description of changes:*
- Use `@NoMuzzle` annotation when accessing `getXrayTraceId` in Lambda
Context Object, which avoids OTel's muzzle check. If `NoSuchMethodError`
is caught, we do not try this logic again.
- Add unit test for when `getXrayTraceId` throws `NoSuchMethodError`.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
jj22ee added a commit that referenced this pull request Oct 24, 2025
…ect 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.
jj22ee added a commit that referenced this pull request Oct 24, 2025
…Muzzle Check (#1218)

*Issue #, if available:*
-
https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/17954879038/job/51066448865

AWS Lambda Environment may or may not have the `getXrayTraceId` method
in Lambda Context (from Lambda Core dependency). This will cause OTel's
Muzzle Check to disable the AWS Lambda Instrumentation in the event that
it isn't present, causing no Lambda Function Handler Span to appear

Fix of previous PR:
#1191

*Description of changes:*
- Use `@NoMuzzle` annotation when accessing `getXrayTraceId` in Lambda
Context Object, which avoids OTel's muzzle check. If `NoSuchMethodError`
is caught, we do not try this logic again.
- Add unit test for when `getXrayTraceId` throws `NoSuchMethodError`.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
jj22ee added a commit that referenced this pull request Oct 27, 2025
…ect 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.
jj22ee added a commit that referenced this pull request Oct 27, 2025
…Muzzle Check (#1218)

*Issue #, if available:*
-
https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/17954879038/job/51066448865

AWS Lambda Environment may or may not have the `getXrayTraceId` method
in Lambda Context (from Lambda Core dependency). This will cause OTel's
Muzzle Check to disable the AWS Lambda Instrumentation in the event that
it isn't present, causing no Lambda Function Handler Span to appear

Fix of previous PR:
#1191

*Description of changes:*
- Use `@NoMuzzle` annotation when accessing `getXrayTraceId` in Lambda
Context Object, which avoids OTel's muzzle check. If `NoSuchMethodError`
is caught, we do not try this logic again.
- Add unit test for when `getXrayTraceId` throws `NoSuchMethodError`.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants