Skip to content

feat(datadog-aws): add AWS SDK tracing for SQS, SNS, and EventBridge - #189

Open
Dogbu-cyber wants to merge 85 commits into
mainfrom
david.ogbureke/aws-sdk-rust
Open

feat(datadog-aws): add AWS SDK tracing for SQS, SNS, and EventBridge#189
Dogbu-cyber wants to merge 85 commits into
mainfrom
david.ogbureke/aws-sdk-rust

Conversation

@Dogbu-cyber

@Dogbu-cyber Dogbu-cyber commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds Datadog trace context propagation for the AWS SDK for Rust, covering SQS, SNS, and EventBridge through separate service crates. Each service crate depends only on its matching AWS SDK crate, with shared span and attribute logic in datadog-aws-core.

Ref: #190
Jira: IDMPL-570

Crate architecture

instrumentation/
├── datadog-aws-core/             # shared request span lifecycle, propagation headers, attribute keys
├── datadog-aws-core-test-utils/  # shared integration/unit test helpers, not published
├── datadog-aws-sqs/              # SQS SDK interceptor and SQS context extraction
├── datadog-aws-sns/              # SNS SDK interceptor
├── datadog-aws-eventbridge/      # EventBridge SDK interceptor
└── datadog-aws-lambda/           # existing Lambda crate, updated for publishing/dependency cleanup

Usage

use datadog_aws_sns::ConfigExt as _;

let config = aws_sdk_sns::config::Builder::from(&sdk_config)
    .datadog_tracing() // install Datadog tracing interceptor
    .build();

let client = aws_sdk_sns::Client::from_conf(config);

Supported behavior

Service Context injection Service-specific span tags Injection point
SQS SendMessage, SendMessageBatch queue tags for send, receive, and delete operations; batch/message counts where available; send message ID; receive span links _datadog message attribute as String JSON
SNS Publish, PublishBatch topic/target tags for publish, batch, topic, subscription, and permission operations; batch counts where available _datadog message attribute as Binary JSON
EventBridge PutEvents rule tags for rule/target operations; batch counts for PutEvents top-level _datadog field in each event detail JSON object

Each instrumented AWS call creates a client span named sqs.request, sns.request, or eventbridge.request, with common Datadog/OpenTelemetry attributes including aws.service, aws.operation, aws.region, aws.partition, resource.name, operation.name, span.kind, HTTP method/URL/status, AWS user agent, and AWS request ID.

Notable details

  • SQS receive requests automatically request the _datadog message attribute, expose datadog_aws_sqs::extract_context, and add span links for received messages with valid propagated context.
  • SQS and SNS respect the AWS 10-message-attribute limit, but replace an existing stale _datadog attribute when present.
  • SNS uses Binary message attributes for _datadog to avoid SNS subscription filter policy interference.
  • EventBridge injects only into existing top-level JSON object details, replaces an existing top-level _datadog, preserves nested _datadog fields, skips missing/invalid/non-object details, and skips details larger than 1 MiB.
  • Injection failures never fail the AWS SDK call; they are skipped and logged at debug level.
  • Integration tests cover successful injection, span tags, error status handling, SQS receive links, batch message counts, and EventBridge detail rewrite edge cases.

Trace Examples

Lambda: SQS.SendMessage and EventBridge.PutEvents

image

SQS.SendMessageBatch

image

SQS.ReceiveMessage

image

@Dogbu-cyber Dogbu-cyber added the enhancement New feature or request label Mar 17, 2026
@Dogbu-cyber
Dogbu-cyber marked this pull request as ready for review March 17, 2026 22:01
@Dogbu-cyber
Dogbu-cyber requested a review from a team as a code owner March 17, 2026 22:01
Comment thread integrations/aws/aws-sdk-rust/README.md Outdated
@ygree

ygree commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 302fbb5267

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread integrations/aws/aws-sdk-rust/Cargo.toml Outdated
Comment thread integrations/aws/aws-sdk-rust/src/services/sns.rs Outdated
Comment thread integrations/aws/aws-sdk-rust/src/services/sqs.rs Outdated
@Dogbu-cyber
Dogbu-cyber changed the base branch from main to david.ogbureke/ci-integration-msrv March 22, 2026 00:54
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch from ee01b82 to 612838b Compare March 22, 2026 00:55
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/ci-integration-msrv branch 2 times, most recently from 141c5dd to 1184437 Compare March 22, 2026 20:52
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch from 612838b to 4f7442a Compare March 23, 2026 14:54
@Dogbu-cyber Dogbu-cyber changed the title AWS SDK Integration feat(datadog-aws-sdk): add trace context injection for SQS, SNS, and EventBridge Mar 23, 2026

@joeyzhao2018 joeyzhao2018 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.

LGTM

@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch from 3fa3937 to 80424aa Compare March 30, 2026 19:20
@Dogbu-cyber

Copy link
Copy Markdown
Contributor Author

@codex review

@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch from 80424aa to 80fedd0 Compare March 30, 2026 19:26

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80424aa3a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread instrumentation/datadog-aws-eventbridge/src/lib.rs Outdated
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/ci-integration-msrv branch 2 times, most recently from 17f2c7a to 78a6876 Compare March 30, 2026 20:30
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch from 80fedd0 to 18c7914 Compare March 30, 2026 20:48
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/ci-integration-msrv branch from 78a6876 to bf4ea81 Compare April 2, 2026 14:54
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch 2 times, most recently from 35b2e4f to 7d1fbbe Compare April 2, 2026 15:32
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch from 29211f0 to d999596 Compare April 13, 2026 12:51
Comment thread instrumentation/aws/datadog-aws/tests/integration.rs Outdated
Comment thread instrumentation/aws/datadog-aws/src/interceptor.rs Outdated
@Dogbu-cyber
Dogbu-cyber force-pushed the david.ogbureke/aws-sdk-rust branch 2 times, most recently from 7e64f6f to f1e120e Compare April 14, 2026 18:06
@ygree
ygree force-pushed the david.ogbureke/aws-sdk-rust branch from b9f8ecf to f559889 Compare June 13, 2026 00:39
Read `_datadog` from both string and binary SQS message attributes so
SNS-propagated context can be extracted.
@ygree
ygree force-pushed the david.ogbureke/aws-sdk-rust branch from 86a98be to ae2e2b7 Compare June 13, 2026 01:07
@ygree
ygree force-pushed the david.ogbureke/aws-sdk-rust branch from f548ec1 to af0a474 Compare July 20, 2026 20:45
@ygree
ygree requested a review from Copilot July 20, 2026 20:46

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 Datadog trace context injection for the AWS SDK for Rust by introducing three service-specific interceptor crates (SQS, SNS, EventBridge) built on a shared core, plus shared test infrastructure. This fits into the instrumentation/ workspace to let users depend only on the AWS SDK crate(s) they actually use.

Changes:

  • Introduce datadog-aws-core request-span helpers + shared attribute keys used by all service interceptors.
  • Add datadog-aws-sqs, datadog-aws-sns, and datadog-aws-eventbridge crates implementing AWS SDK interceptors and context injection at service-appropriate locations.
  • Add datadog-aws-core-test-utils and integration tests for each service crate using a mock AWS endpoint + in-memory OTel exporter.

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
instrumentation/Cargo.toml Expands the instrumentation workspace members and shared dependencies.
instrumentation/Cargo.lock Updates lockfile for newly added AWS SDK + test dependencies.
instrumentation/datadog-aws-core/Cargo.toml Defines the shared core crate package + dependencies.
instrumentation/datadog-aws-core/src/lib.rs Exposes core request span utilities and attribute keys.
instrumentation/datadog-aws-core/src/attribute_keys.rs Adds shared span attribute keys and propagation payload keys.
instrumentation/datadog-aws-core/src/request_span.rs Implements common span lifecycle helpers used by all interceptors.
instrumentation/datadog-aws-core-test-utils/Cargo.toml Adds a non-published test-utils crate for integration/unit test helpers.
instrumentation/datadog-aws-core-test-utils/src/lib.rs Exposes integration and unit test helper modules.
instrumentation/datadog-aws-core-test-utils/src/integration_test_helpers.rs Provides mock AWS server + tracer setup used by service integration tests.
instrumentation/datadog-aws-core-test-utils/src/test_helpers.rs Provides a lightweight test propagator + context helpers for unit tests.
instrumentation/datadog-aws-eventbridge/Cargo.toml Defines the EventBridge interceptor crate and deps.
instrumentation/datadog-aws-eventbridge/src/lib.rs Implements EventBridge interceptor + _datadog injection into detail JSON.
instrumentation/datadog-aws-eventbridge/tests/integration.rs Adds integration coverage for EventBridge span tags and detail injection.
instrumentation/datadog-aws-sns/Cargo.toml Defines the SNS interceptor crate and deps.
instrumentation/datadog-aws-sns/src/lib.rs Implements SNS interceptor + binary MessageAttribute injection.
instrumentation/datadog-aws-sns/tests/integration.rs Adds integration coverage for SNS span tags and binary attribute injection.
instrumentation/datadog-aws-sqs/Cargo.toml Defines the SQS interceptor crate and deps.
instrumentation/datadog-aws-sqs/src/lib.rs Implements SQS interceptor + _datadog MessageAttribute injection and context extraction/linking on receive.
instrumentation/datadog-aws-sqs/tests/integration.rs Adds integration coverage for SQS injection, receive linking, queue parsing, and error tagging.
instrumentation/datadog-aws-lambda/Cargo.toml Adjusts Lambda crate versioning and switches datadog-opentelemetry dependency to crates.io.
instrumentation/datadog-aws-lambda/src/invocation.rs Minor span attribute setting refactor (uses set_attributes).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread instrumentation/datadog-aws-core/src/request_span.rs
Comment thread instrumentation/datadog-aws-eventbridge/src/lib.rs
Comment thread instrumentation/datadog-aws-eventbridge/src/lib.rs Outdated
@ygree ygree self-assigned this Jul 28, 2026
Set the count on SQS SendMessageBatch, SQS ReceiveMessage, EventBridge
PutEvents, and SNS PublishBatch request spans.
@ygree
ygree force-pushed the david.ogbureke/aws-sdk-rust branch from 922151b to ebbe4c3 Compare July 29, 2026 18:11
@ygree ygree changed the title feat(datadog-aws): add per-service interceptor crates for SQS, SNS, and EventBridge feat(datadog-aws): add AWS SDK tracing for SQS, SNS, and EventBridge Jul 29, 2026
@ygree

ygree commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de91cb886b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


[dependencies]
datadog-aws-core = { workspace = true }
aws-sdk-eventbridge = "1.104.0"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Regenerate the third-party license inventory

This commit introduces the AWS SDK, Smithy, and test dependency graphs, but LICENSE-3rdparty.csv is unchanged and contains none of the new AWS or wiremock packages. CONTRIBUTING.md explicitly requires regenerating and committing this inventory whenever dependencies change, so the new publishable crates currently ship without the repository's required third-party attribution; update the inventory, and if the existing generator ignores the nested instrumentation workspace, extend its invocation accordingly.

AGENTS.md reference: AGENTS.md:L3-L4

Useful? React with 👍 / 👎.

Comment on lines +232 to +233
if attrs.len() < MAX_MESSAGE_ATTRIBUTES || attrs.contains_key(DATADOG_ATTRIBUTE_KEY) {
attrs.insert(DATADOG_ATTRIBUTE_KEY.to_string(), datadog_attr);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard SNS injection against the total message-size limit

When a publish payload is already near SNS's 256 KiB message-size limit, inserting this binary attribute—or replacing a smaller existing _datadog value—can push the message over the service limit and turn a previously valid Publish or PublishBatch request into a rejection. The attribute-count guard does not account for serialized attribute size, so injection should be skipped when its size delta would exceed the SNS limit.

Useful? React with 👍 / 👎.

Comment on lines +371 to +372
if attrs.len() < MAX_MESSAGE_ATTRIBUTES || attrs.contains_key(DATADOG_ATTRIBUTE_KEY) {
attrs.insert(DATADOG_ATTRIBUTE_KEY.to_string(), datadog_attr);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard SQS injection against the total message-size limit

For a message whose body and existing attributes are close to SQS's 1 MiB limit, adding this string attribute—or replacing a smaller _datadog value—can make an otherwise valid SendMessage or batch entry exceed the service quota and fail. Checking only the number of attributes cannot prevent this production-visible behavior; skip injection when the serialized size delta would cross the SQS message limit.

Useful? React with 👍 / 👎.

Comment on lines +105 to +106
let attrs = message.message_attributes.as_ref()?;
let datadog_attr = attrs.get(DATADOG_ATTRIBUTE_KEY)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Extract trace context from the default SNS envelope

For an SNS-to-SQS subscription using the default RawMessageDelivery = false, SNS places the binary _datadog attribute inside the JSON notification envelope in Message::body, not in the SQS message-attribute map. Returning immediately when message.message_attributes is absent therefore makes extract_context return None, and the receive interceptor creates no link for the default SNS-to-SQS configuration even though the SNS interceptor injected context; parse the SNS envelope as a fallback and decode its binary attribute.

Useful? React with 👍 / 👎.

Comment on lines +125 to +127
} else if let Some(input) = input.downcast_ref::<SubscribeInput>() {
topic_arn = input.topic_arn.as_deref();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Tag all SNS requests that carry a topic ARN

Operations such as AddPermission and DeleteTopic also carry a topic_arn, but their input types are absent from this dispatch chain, so their request spans omit topicname while otherwise equivalent operations such as RemovePermission and GetTopicAttributes include it. This produces inconsistent resource attribution for common SNS operations; handle every ARN-bearing input type rather than limiting extraction to this subset.

Useful? React with 👍 / 👎.

Comment on lines +179 to +181
} else if let Some(input) = input.downcast_ref::<DeleteMessageBatchInput>() {
queue_url = input.queue_url.as_deref();
batch_message_count = Some(input.entries.as_ref().map_or(0, Vec::len) as i64);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Tag all SQS requests that carry a queue URL

The dispatch only extracts queue_url for send, receive, and delete-message inputs. Queue-scoped operations such as PurgeQueue, DeleteQueue, GetQueueAttributes, and ChangeMessageVisibility therefore create spans without queuename or cloud.resource_id even though their requests contain the same queue URL, making resource attribution depend incorrectly on the operation; extend extraction to the remaining queue-scoped input types.

Useful? React with 👍 / 👎.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants