Repository navigation
Propagate Data Streams context from EventBridge events to SQS consumers - #13585
robcarlan-datadog wants to merge 8 commits into
Conversation
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eedcfadb3f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Batched EventBridge messages can inherit the wrong producer pathway, and envelope extraction drops usable X-Ray system headers. Deeply nested message bodies can also let a stack overflow escape into the consumer application.
🤖 Bits Code Review · Commit 96b3a3b
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75e30aecf8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Please try again by commenting @datadog review.
There was a problem hiding this comment.
The PR propagates EventBridge trace and Data Streams context to SQS consumers.
EventBridge-only batches now extract each message's context independently.
X-Ray header preservation, unnecessary parsing, and queue-time ancestry are fixed.
Mixed EventBridge/SQS batches can still report the wrong producer pathway.
Malformed bodies can still bypass the nesting guard and let a stack overflow escape into the application.
🤖 Bits Code Review · Commit 8c4e062
There was a problem hiding this comment.
More details
The PR propagates EventBridge trace and Data Streams context through SQS message bodies.
With DSM enabled, mixed batches now extract independent contexts after an EventBridge-derived parent.
Parser stack overflows now fall back to ordinary SQS handling.
Earlier X-Ray propagation, unnecessary parsing, and queue-time ancestry issues remain fixed.
No review findings remain open.
🤖 Bits Code Review · Commit f53dd78
EventBridge publishers inject the Data Streams pathway into detail._datadog of each event, but events delivered to an SQS target arrive with that context in the message body only. The SQS consumer instrumentation reads the _datadog message attribute, which EventBridge does not set, so the pathway ended at the bus and the consumer's checkpoint started a fresh one. Parse the EventBridge envelope from the body when the message has no _datadog attribute, extract the trace and pathway context from detail._datadog, and set the consume checkpoint with EventBridge edge tags (direction:in, type:eventbridge, exchange:bus, topic:detail-type) so the edge attaches to the bus. Messages carrying the _datadog attribute keep the existing SQS path; the parse only runs when the attribute is absent and cheap checks pass, and fails silently back to plain SQS tags. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
The module tests only load instrumentations reachable from their declared dependencies, so receiving from SQS never went through the consumer instrumentation and the data streams groups never appeared. Enable data streams at the harness level and add the SQS instrumentation as a test dependency so the checkpoint test observes the real consume path. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
Reformat the new SQS consumer classes to the repo style; no semantic change. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
Bound the JSON nesting depth of EventBridge envelope bodies before parsing, so a deeply nested SQS message body can no longer overflow the stack while the tracer inspects it; such bodies now fall back to plain SQS handling. Parse the envelope only when its result can be used: when data streams monitoring is enabled, or before the batch context has been extracted. Extract EventBridge message context through the regular SQS message visitor combined with the envelope attributes, so SQS system trace headers (such as the X-Ray AWSTraceHeader) keep working, and extract each message's own context within a receive batch instead of inheriting the first message's. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
…messages The _datadog parser gated pathway forwarding on the startup Config, so enabling DSM through remote config produced EventBridge checkpoints without the producer's pathway. It now reads traceConfig(), like TracingIterator. EventBridge messages after the first in a batch extract their own context, which skipped the Sqs.DeliverMessage span. The time-in-queue span is now started for every message that extracts its own context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The repo no longer accepts new Groovy test files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…flow When an EventBridge event came first in a receive batch, later plain SQS messages inherited its context and reported the EventBridge pathway as their parent. With DSM on, they now extract their own context when the batch context came from an EventBridge message. Batches with only plain SQS messages behave as before. The envelope depth scan can undercount on malformed bodies, so tryParseFrom also catches StackOverflowError and falls back to plain SQS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f53dd78 to
3f71ff6
Compare
There was a problem hiding this comment.
EventBridge context extraction materializes the entire application payload on the consumer thread, making tracer allocation scale with message contents rather than propagation metadata. Selective parsing would avoid the unnecessary allocations.
🤖 Bits Code Review · Commit 3f71ff6
Add JsonReader.skipValue so EventBridgeMessage reads only detail-type and detail._datadog, mirroring the v1 SQS body extractor, instead of building maps, lists and strings for the entire application payload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
More details
The PR propagates EventBridge trace and Data Streams context to SQS consumers, linking consumer checkpoints to their publishers. Selective parsing fixes the earlier full-payload allocation finding by skipping unrelated values; the incremental review identified no new reportable issues, leaving no open findings.
🤖 Bits Code Review · Commit 6d7d32a
What Does This Do
When a received SQS message has no
_datadogmessage attribute, the SQS v2 consumer instrumentation now parses the body as an EventBridge envelope. If the event carriesdetail._datadog, the trace and Data Streams pathway context are extracted from it and the consume checkpoint is set with EventBridge edge tags (direction:in,type:eventbridge,exchange:<bus>,topic:<detail-type>) instead of the plain SQS ones, so the consumer's checkpoint chains onto the publisher's pathway rather than starting a new one.Motivation
Publishers to EventBridge inject the Data Streams pathway into
detail._datadogof each event. Events routed to an SQS target arrive with that context in the message body only — EventBridge does not set SQS message attributes — so the SQS consumer instrumentation never saw it and the pathway ended at the bus.Additional Notes
The parse only runs when the
_datadogattribute is absent and cheap prefix/substring checks pass, and fails silently back to plain SQS tags, so the consume hot path only pays for messages that can actually carry the context.DatadogAttributeParsergains a map-based overload so the envelope's parsed attributes reuse the same key handling as the string form. The bus name inx-datadog-resource-nameis normalized the same way the publisher normalizes its own tags, so producer and consumer edges agree onexchange.Testing
LocalStack integration test in
aws-java-eventbridge-2.0publishing through a bus with an SQS target, asserting the consumer stats groupparentHashequals the producer's hash with the EventBridge tags; unit tests for the envelope parser (valid envelope, ARN normalization, default bus fallback, attribute short-circuit, non-EventBridge bodies). Existing SQS and agent-bootstrap suites pass unchanged. Also verified end to end with a producer and consumer app against a real Datadog Agent: the consumer reportsdirection:in,type:eventbridge,parent_hashequal to the producer's hash, with sane latency.🤖 Generated with Claude Code