Repository navigation
feat(contrib/cloud.google.com/go/pubsub): add Data Streams checkpoints - #5946
robcarlan-datadog wants to merge 3 commits into
Conversation
Go Pub/Sub publishers and consumers were missing from Data Streams Monitoring, so pathways broke at Go hops. TracePublish now sets a produce checkpoint and injects the pathway into the message attributes; TraceReceiveFunc extracts it, sets a consume checkpoint, and returns it in the handler context so downstream publishes chain. Consumes are tagged by subscription, matching the Java tracer's convention. Gated on DD_DATA_STREAMS_ENABLED, off by default. One change covers pubsub.v1, pubsub.v2 and Orchestrion, which all share the pubsubtrace package. internal/datastreams: accept "subscription" as an edge tag key so subscription tags participate in the pathway hash. Environment: Datadog workspace Co-Authored-By: Claude Code claude-glm-5.3 <noreply@anthropic.com>
Config Audit |
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 3 Pipeline jobs failed
ℹ️ InfoNo other issues found (see more)🧪 All tests passed 🎯 Code Coverage (details) Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: 5fa8f6d | Docs | View more details | Give us feedback! |
BenchmarksBenchmark execution time: 2026-11-25 23:15:42 Comparing candidate commit 5fa8f6d in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 414 metrics, 1 unstable metrics.
|
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: 2f5aefdb82
ℹ️ 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.
When a receive callback context already contains a DSM pathway, the merge can randomly discard the new consume checkpoint. Forwarded messages can consequently omit the Pub/Sub consume hop from their pathway.
🤖 Bits Code Review · Commit 2f5aefd
…terministic when the handler context carries one When a receive callback's context already carries a DSM pathway, MergeContexts picked one of the two pathways at random, so downstream publishes could bypass the consume checkpoint about half the time. consumeCheckpoint now chains the checkpoint on the pathway extracted from the message attributes and attaches the result to the callback context unconditionally, preserving its span and other values. Environment: Datadog workspace Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
@DataDog review |
There was a problem hiding this comment.
More details
The receive path overrides unrelated inherited pathways with the message-derived checkpoint while preserving the handler’s span and context, addressing the edge case discussed on the PR. The completed static reviewer returned no reportable findings.
🤖 Bits Code Review · Commit d6b84c9
| ) | ||
|
|
||
| var hashableEdgeTags = map[string]struct{}{"event_type": {}, "exchange": {}, "group": {}, "kafka_cluster_id": {}, "topic": {}, "type": {}, "direction": {}, "segment_name": {}} | ||
| var hashableEdgeTags = map[string]struct{}{"event_type": {}, "exchange": {}, "group": {}, "kafka_cluster_id": {}, "subscription": {}, "topic": {}, "type": {}, "direction": {}, "segment_name": {}} |
There was a problem hiding this comment.
This needs a test for subscription. I removed it from hashableEdgeTags and all the pubsubtrace DSM tests still pass (each hash just drops the tag on both sides). Adding {"subscription:orders", true} to the isWellFormedEdgeTag table in pathway_test.go would cover it.
There was a problem hiding this comment.
Added {"subscription:orders", true} to the isWellFormedEdgeTag table in 5fa8f6d.
| if msg == nil { | ||
| return ctx | ||
| } | ||
| parent := datastreams.ExtractFromBase64Carrier(context.Background(), dataStreamsCarrier(msg.Attributes)) |
There was a problem hiding this comment.
This should have a comment on why the parent comes from the message attributes and replaces the pathway in ctx instead of merging, it's hard to tell without the earlier review thread. Something like:
// The checkpoint uses the pathway in the message attributes as its parent,
// not the pathway in ctx. ctx can already carry a pathway from another
// consumer, and datastreams.MergeContexts selects one pathway at random, so
// consumeCheckpoint replaces the pathway in ctx.There was a problem hiding this comment.
Added a shorter version of this above the extract in 5fa8f6d.
Cover the subscription edge tag in the isWellFormedEdgeTag table, explain why consumeCheckpoint replaces the handler context's pathway, and drop nil-message guards that callers already make unreachable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Error Tracking AuditBoth |
What
Adds Data Streams Monitoring checkpoints to the shared
pubsubtracepackage, sopubsub.v1,pubsub.v2and Orchestrion all get them from one change. Go Pub/Sub hops were invisible to DSM, so pathways through mixed-language pipelines broke at their Go services.TracePublishsets adirection:out, topic:<topic>, type:google-pubsubcheckpoint and injects the base64 pathway into the message attributes, alongside the trace context.TraceReceiveFuncextracts the pathway from the attributes, sets adirection:incheckpoint, and returns it in the handler context, so a consumer that publishes onward chains through the context. Consumes are tagged by subscription, matching the Java tracer's convention for Pub/Sub; a cross-tracer standardization of this tag is underway andconsumeEdgeTagsis the single place to flip it. Gated onDD_DATA_STREAMS_ENABLED, off by default.Also accepts
subscriptionas an edge tag key ininternal/datastreams, without which subscription tags are dropped from the pathway hash; no other integration uses that key today.Why
Java and Node.js already instrument Pub/Sub for DSM; Go was the gap.
Testing
Unit tests in
pubsubtracefollow the sarama integration's pattern: pathway hash equality for produce, consume chained on produce, forwarding through the handler context, and no-op behavior when the flag is off.pubsub.v1,pubsub.v2andinternal/datastreamssuites pass;gofmtandgo vetclean.🤖 Generated with Claude Code