Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add instrumentation for Lambda Java interface HandleStreamRequest #13466

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

lukeina2z
Copy link
Contributor

Fixes #13444

Problem:
AWS Lambda for Java provides two handler interfaces:
com.amazonaws.services.lambda.runtime.RequestHandler
com.amazonaws.services.lambda.runtime.RequestStreamHandler
However, instrumentation for RequestStreamHandler is missing in the OpenTelemetry Java agent.

Fix:
Added instrumentation support for RequestStreamHandler.

Test:
Pass with green:
./gradlew spotlessCheck
./gradlew clean assemble
./gradlew instrumentation:test
./gradlew :smoke-tests:test

Manual end-to-end tests pass:

  • Deployed Lambda functions with Spring Boot 3 and Amazon Serverless Java Container.
  • Enabled application signals, observed broken traces.
  • Disabled application signals and added a private build of the Java layer for Lambda with this change.
  • Verified traces and spans are now correct.

Backward Compatibility:
No risk of breaking existing functionality.
The change only adds instrumentation for RequestStreamHandler without modifying existing behavior for RequestHandler. Existing users not using RequestStreamHandler remain unaffected.

Problem:
AWS Lambda for Java provides two handler interfaces:
com.amazonaws.services.lambda.runtime.RequestHandler
com.amazonaws.services.lambda.runtime.RequestStreamHandler
However, instrumentation for RequestStreamHandler is missing in the OpenTelemetry Java agent.

Fix:
Added instrumentation support for RequestStreamHandler.

Test:
Pass with green:
 ./gradlew spotlessCheck
 ./gradlew clean assemble
 ./gradlew instrumentation:test
 ./gradlew :smoke-tests:test

Manual end-to-end tests pass:
- Deployed Lambda functions with Spring Boot 3 and Amazon Serverless Java Container.
- Enabled application signals, observed broken traces.
- Disabled application signals and added a private build of the Java layer for Lambda with this change.
- Verified traces and spans are now correct.

Backward Compatibility:
No risk of breaking existing functionality.
The change only adds instrumentation for RequestStreamHandler without modifying existing behavior for RequestHandler. Existing users not using RequestStreamHandler remain unaffected.
@lukeina2z lukeina2z requested a review from a team as a code owner March 6, 2025 22:34
Copy link

linux-foundation-easycla bot commented Mar 6, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: lukeina2z / name: Luke (GuangHui) Zhang (2c3fa57)

@@ -34,6 +35,8 @@ public boolean isHelperClass(String className) {

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new AwsLambdaRequestHandlerInstrumentation());
return Arrays.asList(
Copy link
Contributor

Choose a reason for hiding this comment

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

usually we static import the asList method when it is used in instrumentation module.

Copy link
Member

Choose a reason for hiding this comment

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

some day I'm going to write an automation for this...

@laurit laurit added this to the v2.14.0 milestone Mar 7, 2025
@trask trask merged commit 3c14532 into open-telemetry:main Mar 12, 2025
85 checks passed
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.

AWS Lambda Java: Missing Instrumentation for RequestStreamHandler in the Java Agent
3 participants