Skip to content

feat(datadog-aws): add per-service interceptor crates for SQS, SNS, and EventBridge#189

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

feat(datadog-aws): add per-service interceptor crates for SQS, SNS, and EventBridge#189
Dogbu-cyber wants to merge 73 commits into
mainfrom
david.ogbureke/aws-sdk-rust

Conversation

@Dogbu-cyber

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

Copy link
Copy Markdown
Contributor

PR Stack: #194 (workspace setup) -> #189 (aws-sdk injection)

What does this PR do?

Adds trace context injection for the AWS SDK for Rust via three focused interceptor crates. Each crate pulls in only the AWS SDK dependency it needs -- users add only what they use.

Ref: #190

Crate architecture

instrumentation/
├── datadog-aws-core/       # shared -- ServiceHandler trait, generic AwsInterceptor,
│                           #            attribute_keys, limits
├── datadog-aws-core-test-utils/       # common test helpers (not published)
├── datadog-aws-sqs/        # SqsInterceptor
├── datadog-aws-sns/        # SnsInterceptor
└── datadog-aws-eventbridge/ # EventBridgeInterceptor

Usage

use datadog_aws_sns::ConfigExt as _;

let sns = aws_sdk_sns::Client::from_conf(config.to_builder()
  .datadog_tracing() // instrument
  .build());

Supported operations

Service Inject operations Tag-only operations Injection point
SQS SendMessage, SendMessageBatch ReceiveMessage, DeleteMessage, DeleteMessageBatch _datadog MessageAttribute (String, JSON)
SNS Publish, PublishBatch GetTopicAttributes, ListSubscriptionsByTopic, Subscribe, CreateTopic, etc. _datadog MessageAttribute (Binary) -- avoids subscription filter policy interference
EventBridge PutEvents PutRule, PutTargets, DescribeRule, etc. _datadog key in event detail JSON

Each interceptor also creates a client span (sqs.request, sns.request, eventbridge.request) with standard Datadog tags: aws.service, aws.operation, aws.region, aws.partition, resource.name, operation.name, etc.

Design notes

  • datadog-aws-core exposes shared request span helpers and common attributes; each service crate owns its concrete AWS SDK interceptor implementation and uses those helpers for span lifecycle, service-specific tags, and trace-context injection.
  • Injection never fails an AWS call -- errors are swallowed and logged at debug level
  • SQS/SNS respect the 10-attribute cap but overwrite a stale _datadog attribute if present
  • EventBridge skips injection if the resulting detail would exceed 1 MB
  • Integration test infrastructure (mock_aws, init_test_tracer, sdk_config, span_attrs) lives in datadog-aws-core-test-utils

Trace Example

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 on lines +148 to +150
// EventBridge entries have a 1 MB detail size limit.
if new_detail.len() > ONE_MB {
continue;

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 Validate full PutEvents entry size before mutating Detail

The size guard only checks new_detail.len(), but EventBridge enforces the 1 MB limit on the entire PutEventsRequestEntry payload, not just the Detail field. If an entry is already near the limit because of Source, DetailType, Resources, etc., adding _datadog can push the total entry size over quota and make PutEvents fail, even though tracing is intended to be non-intrusive. This should use the documented entry-size calculation (or equivalent full-entry check) before writing the mutated detail.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR This is a valid concern. I'm thinking about dropping this check because it's not correct or useful.

The limit is documented as a service-side contract. AWS’s current EventBridge API reference says PutEvents total entry size must be less than 1 MB, and the user guide says the whole request must stay under 1,048,576 bytes, with a single entry allowed to use that full budget if it is the only one. Invalid entries are reported back by the service through PutEventsResultEntry.ErrorCode / ErrorMessage, which is consistent with backend enforcement rather than SDK preflight. Sources: PutEvents API, PutEvents user guide, PutEventsResultEntry.

The latest generated Rust SDK docs still say 256KB

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should keep the check for now, just to provide an upper limit. If the payload exceeds the limit for any reason, we can skip the injection path altogether, as such a request will be rejected by the backend anyway.

@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
let new_detail = match rewrite_json_object_field(detail, DATADOG_ATTRIBUTE_KEY, &trace_ctx)
{
Ok(detail) => detail,
Err(_) => continue,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Would be nice to include a debug level log here, or somehow otherwise inform the user why injection failed.

return;
};
let Ok(dd_attr) = build_datadog_attribute(trace_headers) else {
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In all the cases where we return early, would be nice to have some debug level logging.

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

4 participants