Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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)

@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
lukeina2z added a commit to aws-observability/aws-otel-java-instrumentation that referenced this pull request Aug 22, 2025
…8.0 (#1156)

This updates upstream dependency OTel Java Agent to v2.18.1 and upgrades
upstream OTel Contrib to v1.48.0.

It removes two patch files, as those code has been migrated to upstream.

For the OTel Java Contrib patch, it has been replaced by PR-1959
open-telemetry/opentelemetry-java-contrib#1959
, which is included in the OTel Java Contrib v1.48.0 release.

For the OTel Java Agent patch for the Lambda stream handler, it has been
replaced by PR-13466
open-telemetry/opentelemetry-java-instrumentation#13466
, which is included in the OTel Java Agent v2.18.1 release.

Tests:
- Unit tests pass: ./gradlew build test
- Smoke/Contract tests pass: ./gradlew
appsignals-tests:contract-tests:contractTests
- X-Ray remote sampling service end-to-end manual tests pass
- EC2 end-to-end tests with SpringBoot Java app pass
- Lambda end-to-end tests with SpringBoot Java app pass

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.

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