Skip to content

Conversation

RanVaknin
Copy link
Contributor

This PR adds:

  1. New thread-context code package that provides thread-local storage utilities for sharing data across components, specifically to support trace ID propagation, and
  2. Support for trace id propagation using the new threadStorage class

Background

Previously, we implemented trace ID propagation using SLF4J's MDC in PR #6363, but this was
reverted because the MDC interface exists but the implementation is not provided by the SDK, Lambda runtime, or X-Ray SDK.

Solution

Added a small ThreadStorage utility class that provides thread local key value storage using ThreadLocal<Map<String, String>>. For this case, it allows the Lambda Runtime Interface Client, AWS SDK, and X-Ray SDK to share trace context via this one package, but can extended to other use cases.

Example:

ThreadStorage.put("some-value", foo);
String traceId = ThreadStorage.get("some-value");
ThreadStorage.remove("some-value");
ThreadStorage.clear();

@RanVaknin RanVaknin requested a review from a team as a code owner September 3, 2025 17:23
@RanVaknin RanVaknin changed the title Feature/master/lambda trace id thread storage Add ThreadStorage utility class and support for Lambda TraceId propagation Sep 3, 2025
@RanVaknin RanVaknin added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Sep 3, 2025
Copy link

sonarqubecloud bot commented Sep 4, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant