Repository navigation
Recover appended DBM comments from SQL Server activity tail text - #25884
Conversation
The tail_text scan ran the obfuscator without return_json_metadata or collect_comments, so it never returned comments. It also fed a fixed-length cut that can start inside a string literal, which hides any later comments. Read trailing block comments directly from the end instead, and stop sending the raw tail_text in activity payloads. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
evalya-impact-summaryEvalya CI impact |
✅ Dispatcher tests: passed
✅ 46 passed · nothing failed Batches · ✅ batch-01 46/46 Dispatcher finished on |
Co-authored-by: Cursor <cursoragent@cursor.com>
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 1 Pipeline job failed
ℹ️ InfoNo other issues found (see more)🧪 All tests passed 🔄 Datadog retried 1 test - 1 passed on retry 🎯 Code Coverage (details) Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: 3520a89 | Docs | View more details | Give us feedback! |
Co-authored-by: Cursor <cursoragent@cursor.com>
Codex Review SummaryThis 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. |
Disk usage changeCommit Uncompressed
Details
Compressed
Details
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7a280af9e
ℹ️ 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.
Tail-comment recovery bypasses documented collection opt-outs and can misclassify SQL string contents as comments, placing unobfuscated literal values in dd_comments.
🤖 Bits Code Review · Commit c7a280a
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Validation ReportAll 22 validations passed. Show details
|
What does this PR do?
Fixes recovery of appended DBM<>APM comments from the SQL Server activity
tail_text.tail_textobfuscator call withextract_trailing_dbm_comments, which reads/* ... */blocks backward from the end of the text, skipping trailing whitespace and semicolons. A backward scan cannot tell whether a delimiter belongs to a string literal or a line comment, so it only accepts blocks in the tracers'key='value'format that carry a DBM marker, and stops at the first block that does not match. Recovery is skipped whencollect_commentsorcollect_metadatais disabled.tail_textfrom the row before the activity event is sent.The old path could not return comments for two reasons:
_obfuscator_options_for_tail_textdid not setreturn_json_metadata(orcollect_comments), so the agent returned a plain string andobfuscate_sql_with_metadataproduced empty metadata.RIGHT(qt.text, 200)can start inside a string literal. Even with comment collection enabled, the obfuscator treats everything after the unmatched quote as a string and finds no comments.tail_textwas also never removed from the row, so the raw, unobfuscated end of every long batch was sent in activity payloads.Motivation
Found while testing DBM<>APM link propagation end to end against local SQL Server 2022 with dd-trace-java. A
PreparedStatementin service propagation mode, padded past 500 characters, had its appendedddpscomment intail_textbut an emptydd_comments, so the sample had no caller service. Leading comments and short batches are already covered by #24899.Verified with the local-dev MITM capture on Agent 7.85.0
Before the fix injected comments are getting lost so calling service section of a query sample is missing details

After the fix the injected comments are captured properly and we're able to populate calling service metadata

Checklist before requesting review