open-telemetry / open-telemetry/opentelemetry-java-instrumentation

Update Lambda Trace Context Propagation Priority to Use New Lambda Context API

Open
#15,517 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs triage
Dominant language
Java
Stars
2.6k
Forks
1.2k
Avg merge
2d 18h
Merged PRs (30d)
228

Description

Is your feature request related to a problem? Please describe.

In traditional AWS Lambda functions, trace context propagation relies on extracting context from environment variables or system properties.
With the introduction of AWS Lambda Managed Instance, a single runtime instance may process multiple requests rather than just one. To support correct context propagation in this model, AWS Lambda has added a new Lambda API (available in updated Lambda runtime versions) that allows functions to retrieve the upstream trace context directly from the Lambda context.

To ensure accurate and reliable trace propagation across requests, the Lambda instrumentation needs to update its propagation logic.

Describe the solution you'd like

Update the context propagation priority in the AWS Lambda instrumentation as follows:

  1. Use the new Lambda context API, if available, to extract the upstream trace context
  2. Fallback to system properties, if present
  3. Finally fallback to environment variables, as the last resort

This ensures correct context propagation for both traditional single-invoke runtimes and the new Managed Instance model.

Technical details

The new API is introduced in
https://github.com/aws/aws-lambda-java-libs/pull/563

Bump dependency for the new API:

library("com.amazonaws:aws-lambda-java-core:1.4.0")

API:

String com.amazonaws.services.lambda.runtime.Context.getTraceHeader()

Refer to OpenTelemetry .Net https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3410, AWS Lambda .Net has only .Net 8 one runtime version, it does not have to fallback to the environment variable.

Describe alternatives you've considered

No response

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the AWS Lambda instrumentation and inspect the existing trace-context propagation logic and its current dependency declaration. Update the dependency to com.amazonaws:aws-lambda-java-core:1.4.0, use Context.getTraceHeader() before system properties and environment variables, and verify the priority with the relevant Lambda instrumentation tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
cloud, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.