opentelemetry-instrumentation-aws-lambda: add SQS context propagation support#4668
Open
herin049 wants to merge 3 commits into
Open
opentelemetry-instrumentation-aws-lambda: add SQS context propagation support#4668herin049 wants to merge 3 commits into
herin049 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class SQS context propagation support to the AWS Lambda instrumentation by creating an additional SQS “process” CONSUMER span and extracting W3C trace context from SQS message attributes to generate span links (including batch handling). This aligns the Lambda-side trace shape with messaging semantic conventions for SQS batch processing.
Changes:
- Introduces SQS-specific event detection and a helper to create a CONSUMER “process …” span with span links extracted from
messageAttributes. - Updates the Lambda wrapper to set
faas.triggerappropriately for SQS and to route SQS invocations through the new SQS handler wrapper. - Expands mock SQS events and adds comprehensive tests covering links, batching, malformed events, and edge cases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/_sqs.py | Implements SQS event detection, queue name extraction, link extraction from message attributes, and CONSUMER “process” span creation. |
| instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/init.py | Wires SQS handling into the main Lambda wrapper and refactors API Gateway attribute helpers to populate an attributes mapping. |
| instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/sqs_event.py | Adds additional SQS mock events for trace context, batching, malformed inputs, and edge cases. |
| instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py | Updates/extends tests to validate the new two-span SQS behavior, link extraction, batching attributes, and malformed event handling. |
| .changelog/4668.added | Changelog entry for the new SQS context propagation feature. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for SQS context propagation through the usage of a custom extractor for SQS message attributes. Prior work done in adding support for SQS context propagation for JavaScript (see open-telemetry/opentelemetry-js-contrib#2981) was used as a reference for this implementation.
Fixes #4642
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
Additional Resources