Skip to content

Recover appended DBM comments from SQL Server activity tail text - #25884

Merged
eric-weaver merged 7 commits into
masterfrom
eric.weaver/sqlserver-tail-text-comments
Oct 30, 2026
Merged

eric-weaver merged 7 commits into
masterfrom
eric.weaver/sqlserver-tail-text-comments

Conversation

@eric-weaver

@eric-weaver eric-weaver commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes recovery of appended DBM<>APM comments from the SQL Server activity tail_text.

  • Replaces the tail_text obfuscator call with extract_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 when collect_comments or collect_metadata is disabled.
  • Removes tail_text from the row before the activity event is sent.

The old path could not return comments for two reasons:

  1. _obfuscator_options_for_tail_text did not set return_json_metadata (or collect_comments), so the agent returned a plain string and obfuscate_sql_with_metadata produced empty metadata.
  2. 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_text was 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 PreparedStatement in service propagation mode, padded past 500 characters, had its appended ddps comment in tail_text but an empty dd_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
Screenshot 2026-10-30 at 4 13 16 PM

After the fix the injected comments are captured properly and we're able to populate calling service metadata
Screenshot 2026-10-30 at 4 13 22 PM

Checklist before requesting review

  • I self-reviewed the full diff, and this description matches the final change
  • Tests cover the change, or this description explains why none are needed
  • Automated review comments, including Codex review, were addressed or answered
  • I, the human author, understand this change, can explain it to reviewers, and believe it meets the repository standards

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>
eric-weaver and others added 2 commits October 30, 2026 16:08
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

evalya-impact-summary

Evalya CI impact

Impact analysis: RUN-ALL — every test task will run
Trigger:         empty diff (default branch, scheduled run, or shallow-clone fallback)
Test tasks:      0 (all selected)
Publish tasks:   4 (always emitted)
Changed files:   0

Full impact report
Learn more about CI impact filtering

@dd-octo-sts

dd-octo-sts Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

✅ Dispatcher tests: passed

Dispatcher beta: informational only
Existing CI remains the merge signal.

  46/46 jobs

✅ 46 passed · nothing failed

Batches · ✅ batch-01 46/46

Dispatcher finished on c76ed81 — GitHub Run · Dispatcher Logs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests  Code Coverage

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

Validate repository | Run Validations / Validate

View more details · View in GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 1 test - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 91.65% (+1.90%)

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>
@eric-weaver
eric-weaver marked this pull request as ready for review October 30, 2026 20:24
@eric-weaver
eric-weaver requested review from a team as code owners October 30, 2026 20:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T20:27:10.005775Z c7a280a Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dd-octo-sts

dd-octo-sts Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Disk usage change

Commit 3520a89 compared against c76ed81.

Uncompressed

linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
🔺 +1.15 KiB 🔺 +1.15 KiB 🔺 +1.15 KiB 🔺 +1.15 KiB 🔺 +1.15 KiB
Details
Name Version Type linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
sqlserver 23.7.0 Integration 🔺 +1.15 KiB 🔺 +1.15 KiB 🔺 +1.15 KiB 🔺 +1.15 KiB 🔺 +1.15 KiB

Compressed

linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
🔺 +510 B 🔺 +510 B 🔺 +510 B 🔺 +510 B 🔺 +510 B
Details
Name Version Type linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
sqlserver 23.7.0 Integration 🔺 +510 B 🔺 +510 B 🔺 +510 B 🔺 +510 B 🔺 +510 B

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

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

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.

Bits Code Review: FAIL

Tail-comment recovery bypasses documented collection opt-outs and can misclassify SQL string contents as comments, placing unobfuscated literal values in dd_comments.

Open Bits AI session

🤖 Bits Code Review · Commit c7a280a

eric-weaver and others added 2 commits October 30, 2026 16:29
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@dd-octo-sts

dd-octo-sts Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 22 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file ✅
ci Validate CI configuration and code coverage settings ✅
codeowners Validate every integration has a CODEOWNERS entry ✅
config Validate default configuration files against spec.yaml ✅
dep Verify dependency pins are consistent and Agent-compatible ✅
http Validate integrations use the HTTP wrapper correctly ✅
imports Validate check imports do not use deprecated modules ✅
integration-style Validate check code style conventions ✅
jmx-metrics Validate JMX metrics definition files and config ✅
labeler Validate PR labeler config matches integration directories ✅
legacy-signature Validate no integration uses the legacy Agent check signature ✅
license-headers Validate Python files have proper license headers ✅
licenses Validate third-party license attribution list ✅
metadata Validate metadata.csv metric definitions ✅
models Validate configuration data models match spec.yaml ✅
openmetrics Validate OpenMetrics integrations disable the metric limit ✅
package Validate Python package metadata, naming, and wheel contents ✅
pr-description Validate the pull request checklist and visible description length ✅
qa-label Validate the pull request declares whether it needs QA for the next Agent release ✅
readmes Validate README files have required sections ✅
saved-views Validate saved view JSON file structure and fields ✅
version Validate version consistency between package and changelog ✅

View full run

@eric-weaver
eric-weaver added this pull request to the merge queue Oct 30, 2026
Merged via the queue into master with commit 627c14f Oct 30, 2026
85 of 89 checks passed
@eric-weaver
eric-weaver deleted the eric.weaver/sqlserver-tail-text-comments branch October 30, 2026 21:11
@dd-octo-sts dd-octo-sts Bot added this to the 7.87.0 milestone Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants