Skip to content

opentelemetry-instrumentation-aws-lambda: add SQS context propagation support#4668

Open
herin049 wants to merge 3 commits into
open-telemetry:mainfrom
herin049:feat/aws-lambda-sqs-messaging
Open

opentelemetry-instrumentation-aws-lambda: add SQS context propagation support#4668
herin049 wants to merge 3 commits into
open-telemetry:mainfrom
herin049:feat/aws-lambda-sqs-messaging

Conversation

@herin049

@herin049 herin049 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-instrumentation-aws-lambda

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Additional Resources

@herin049 herin049 requested a review from a team as a code owner June 7, 2026 02:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.trigger appropriately 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-aws-lambda: propagate SQS Context

2 participants