-
Notifications
You must be signed in to change notification settings - Fork 944
AWS Lambda Runtime internal handlers need to be ignored from being instrumented and so traced. #10736
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
AWS Lambda Runtime internal handlers need to be ignored from being instrumented and so traced. #10736
Conversation
b931fa8
to
a4ed1bf
Compare
…strumented and so traced. Otherwise, there might be double root spans.
a4ed1bf
to
8621e84
Compare
@serkan-ozal please, it looks like we'll need same check here. |
@cleverchuk I had not added it there because of SQSEvent check here: Line 25 in 4fc3bab
Since |
@serkan-ozal Gotcha. It looks sufficient to not add anymore code. Thanks for pointing that out. |
cc @tylerbenson |
…ed spans (#1000) ### Issue 1 - Duplicate lambda root spans The instrumentation produces 2 lambda root spans upon each invocation of the function. This is a known issue in OTel: open-telemetry/opentelemetry-java-instrumentation#7808 #### Fix - Otel has fixed it in [this PR](open-telemetry/opentelemetry-java-instrumentation#10736) but the change wasn't ported to the 1.x versions. So I took the diff from the upstream commit and made it into a patch that we apply when building the ADOT Java Lambda Layer for v1.33.x. ### Issue 2 - Unsampled spans do not produce Application Signals metrics On lambda environment, we export 100% of the spans to X-Ray to ensure we are able to provide 100% Application Signals metrics. However, currently only the sampled spans show up on the "Services" page and the unsampled spans do not. #### Fix - Upon comparing the sampled vs unsampled spans, I noticed that the unsampled spans are missing the attributes like `aws.local.service` and `aws.local.operation` which are required to generate Application Signals metrics. - The fix is to wrap the `OtlpUdpSpanExporter` instance for unsampled spans with the `AwsMetricAttributesSpanExporter` so that the exported spans have the desired attributes. #### Testing - After creating a layer with the fix, I set the `OTEL_TRACES_SAMPLER` to `always_off`. Then I invoked the function once. - The metrics appeared on the Application Signals console. - See the following screenshots <img width="1722" alt="image" src="https://github.com/user-attachments/assets/fa10e09f-ae24-4ab3-989f-838aacfb7e50" /> <img width="1722" alt="image" src="https://github.com/user-attachments/assets/d777304f-2cd9-4348-8e29-74f4a8b6b917" /> *Description of changes:* By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
V2 PR: open-telemetry/opentelemetry-java-instrumentation#10736 V2 Issue: Non-top level server span created by lambda instrumentation open-telemetry/opentelemetry-java-instrumentation#7808 The fix has been ported to v1 as a patch for non-stream handlers. This change extends the fix to the stream handler in the v1 repository. Testing: All unit tests pass. End-to-end tests pass. Backward Compatibility: No risk of breaking existing functionality. The change only adds instrumentation for RequestStreamHandler without modifying existing behavior for RequestHandler. Existing users who do not use RequestStreamHandler remain unaffected.
…1047) - **V2 Issue:** [Non-top-level server span created by Lambda instrumentation](open-telemetry/opentelemetry-java-instrumentation#7808) - **V2 PR:** [#10736](open-telemetry/opentelemetry-java-instrumentation#10736) The fix has been ported to v1 as a patch for non-stream handlers. This change extends the fix to the stream handler in the v1 repository. ### Testing - All unit tests pass. - End-to-end tests pass. (with Java11, 17, and 21 runtime on Lambda) ### Backward Compatibility - No risk of breaking existing functionality. - The change only adds instrumentation for `RequestStreamHandler` without modifying existing behavior for `RequestHandler`. - Existing users who do not use `RequestStreamHandler` remain unaffected. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
… Otherwise, there might be double root spans.
Fixes #7808