feat(datadog-aws): add AWS SDK tracing for SQS, SNS, and EventBridge - #189
feat(datadog-aws): add AWS SDK tracing for SQS, SNS, and EventBridge#189Dogbu-cyber wants to merge 85 commits into
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 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".
ee01b82 to
612838b
Compare
141c5dd to
1184437
Compare
612838b to
4f7442a
Compare
3fa3937 to
80424aa
Compare
|
@codex review |
80424aa to
80fedd0
Compare
There was a problem hiding this comment.
💡 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".
17f2c7a to
78a6876
Compare
80fedd0 to
18c7914
Compare
78a6876 to
bf4ea81
Compare
35b2e4f to
7d1fbbe
Compare
29211f0 to
d999596
Compare
7e64f6f to
f1e120e
Compare
b9f8ecf to
f559889
Compare
Read `_datadog` from both string and binary SQS message attributes so SNS-propagated context can be extracted.
86a98be to
ae2e2b7
Compare
f548ec1 to
af0a474
Compare
There was a problem hiding this comment.
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-corerequest-span helpers + shared attribute keys used by all service interceptors. - Add
datadog-aws-sqs,datadog-aws-sns, anddatadog-aws-eventbridgecrates implementing AWS SDK interceptors and context injection at service-appropriate locations. - Add
datadog-aws-core-test-utilsand 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.
Set the count on SQS SendMessageBatch, SQS ReceiveMessage, EventBridge PutEvents, and SNS PublishBatch request spans.
922151b to
ebbe4c3
Compare
|
@codex review |
There was a problem hiding this comment.
💡 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" |
There was a problem hiding this comment.
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 👍 / 👎.
| if attrs.len() < MAX_MESSAGE_ATTRIBUTES || attrs.contains_key(DATADOG_ATTRIBUTE_KEY) { | ||
| attrs.insert(DATADOG_ATTRIBUTE_KEY.to_string(), datadog_attr); |
There was a problem hiding this comment.
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 👍 / 👎.
| if attrs.len() < MAX_MESSAGE_ATTRIBUTES || attrs.contains_key(DATADOG_ATTRIBUTE_KEY) { | ||
| attrs.insert(DATADOG_ATTRIBUTE_KEY.to_string(), datadog_attr); |
There was a problem hiding this comment.
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 👍 / 👎.
| let attrs = message.message_attributes.as_ref()?; | ||
| let datadog_attr = attrs.get(DATADOG_ATTRIBUTE_KEY)?; |
There was a problem hiding this comment.
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 👍 / 👎.
| } else if let Some(input) = input.downcast_ref::<SubscribeInput>() { | ||
| topic_arn = input.topic_arn.as_deref(); | ||
| } |
There was a problem hiding this comment.
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 👍 / 👎.
| } 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); |
There was a problem hiding this comment.
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 👍 / 👎.
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
Usage
Supported behavior
SendMessage,SendMessageBatch_datadogmessage attribute as String JSONPublish,PublishBatch_datadogmessage attribute as Binary JSONPutEventsPutEvents_datadogfield in each eventdetailJSON objectEach instrumented AWS call creates a client span named
sqs.request,sns.request, oreventbridge.request, with common Datadog/OpenTelemetry attributes includingaws.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
_datadogmessage attribute, exposedatadog_aws_sqs::extract_context, and add span links for received messages with valid propagated context._datadogattribute when present._datadogto avoid SNS subscription filter policy interference._datadog, preserves nested_datadogfields, skips missing/invalid/non-object details, and skips details larger than 1 MiB.Trace Examples
Lambda: SQS.SendMessage and EventBridge.PutEvents
SQS.SendMessageBatch
SQS.ReceiveMessage