Skip to content

Conversation

RanVaknin
Copy link
Contributor

@RanVaknin RanVaknin commented Sep 4, 2025

This PR adds a new utils-lite code package that provides thread local storage wrapper for sharing data across components, specifically to support lambda trace ID propagation.

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 SdkInternalThreadLocal 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:

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

@RanVaknin RanVaknin requested a review from a team as a code owner September 4, 2025 05:50
@RanVaknin RanVaknin changed the base branch from master to feature/master/utils-lite-lambda-trace September 4, 2025 16:33
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

@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 4, 2025
@@ -175,7 +175,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<version>3.5.0</version>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was bumped because the build was failing with:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.2:shade (default) on project http-client-benchmarks: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.2:shade for parameter Main-Class: Cannot assign configuration entry 'Main-Class' with value 'org.openjdk.jmh.Main' of type java.lang.String to property of type java.util.Map -> [Help 1]

It's not entirely clear why the build fails with it, and why these changes cause this since they seem completely unrelated, but we do have mixed versions of the shade plugin across multiple packages, so i just bumped it to the most recent version

/**
* Utility for thread-local context storage.
*/
@SdkProtectedApi
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could not use SdkInternalApi because the TraceIdExecutionInterceptor (SdkProtectedApi) is using this class and archunit throws an error "no internal APIs across modules"

@RanVaknin RanVaknin merged commit c7f7e42 into feature/master/utils-lite-lambda-trace Sep 5, 2025
30 of 37 checks passed
Copy link

github-actions bot commented Sep 5, 2025

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

2 participants