feat(datastreams): add span tagging and custom timestamp to TrackDataStreamsTransaction#4499
feat(datastreams): add span tagging and custom timestamp to TrackDataStreamsTransaction#4499
Conversation
…on tracking - Add DSMTransactionID and DSMTransactionCheckpoint tag constants to ext/tags.go - Add ctx parameter to TrackDataStreamsTransaction (breaking change) to tag the active span with dsm.transaction.id and dsm.transaction.checkpoint - Add TrackDataStreamsTransactionAt for caller-supplied timestamps - Add Processor.TrackTransactionAt backed by a shared trackTransactionAt helper - Update api.txt and expand test coverage for all new behaviors Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-03-09 17:18:37 Comparing candidate commit 4b37c67 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 156 metrics, 8 unstable metrics.
|
| func SetDataStreamsCheckpoint(context.Context, ...string) (context.Context, bool) | ||
| func SetDataStreamsCheckpointWithParams(context.Context, options.CheckpointParams, ...string) (context.Context, bool) | ||
| func TrackDataStreamsTransaction(string) | ||
| func TrackDataStreamsTransaction(context.Context, string) |
There was a problem hiding this comment.
Shall we keep the existing function to be backwards compatible here?
There was a problem hiding this comment.
its currently used by 1 design partner and this is a feature they had asked for, so i think its okay that its not backwards compatible
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 4b37c67 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5cb113c495
ℹ️ 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".
mtoffl01
left a comment
There was a problem hiding this comment.
Marking this as "request changes" until a clear decision has been made on whether to always add this metadata on spans or to do so only when DSM is enabled.
…egate to At variant Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Why
The first implementation of
TrackDataStreamsTransactionrecorded transaction checkpoints in the DSM processor but did nothing to tie them back to the active trace. Both dd-trace-js and dd-trace-java tag the active span withdsm.transaction.idanddsm.transaction.checkpointwhenever a transaction is tracked — this correlation is what allows the Datadog UI to link a specific transaction to the trace that processed it.Additionally, callers sometimes know the relevant timestamp in advance (e.g. they are gathering data from an external source and want to checkpoint their pipeline with when the data came from). The processor already supports arbitrary timestamps internally, but there was no way to supply one from the public API, so every observation was silently stamped with
time.Now().What
Span tagging —
TrackDataStreamsTransactionnow acceptsctx context.Contextas its first argument. If the context carries an active span, it is tagged withdsm.transaction.idanddsm.transaction.checkpoint, matching the tag names used by dd-trace-java exactly. Passingcontext.Background()skips tagging with no overhead.Custom timestamp — New
TrackDataStreamsTransactionAt(ctx, transactionID, checkpointName, t)lets callers supply the observation time. The processor buckets it into the correct 10-second window just like any other point. Useful when replaying or processing messages that carry their own timestamps.extconstants —ext.DSMTransactionIDandext.DSMTransactionCheckpointare exported so integrations can reference the tag names without hardcoding strings.Breaking change
TrackDataStreamsTransactiongains a leadingcontext.Contextparameter. The only known caller is on a branch; the update is straightforward — pass the context that was already in scope, orcontext.Background().Test plan
TestTrackDataStreamsTransactionTagsSpan— span in context receives both DSM tagsTestTrackDataStreamsTransactionNoSpanInContextNoops— context with no span does not panicTestTrackDataStreamsTransactionAtDelegatesToProcessor—...Atvariant reaches the processorTestTrackDataStreamsTransactionAtTagsSpan—...Atvariant also tags the spanTestTrackTransactionAtUsesProvidedTime— processor stores caller-supplied timestamp, nottime.Now()go build ./...— clean build🤖 Generated with Claude Code