Skip to content

feat(contrib/mark3labs/mcp-go): support redacting tool output in LLMObs traces#4945

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
jb/mcp-configurable-tool-output-redaction
Jul 3, 2026
Merged

feat(contrib/mark3labs/mcp-go): support redacting tool output in LLMObs traces#4945
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
jb/mcp-configurable-tool-output-redaction

Conversation

@jboolean

@jboolean jboolean commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This PR stack ports functionality added in the clone of this contrib in dd-source back to dd-trace-go.

Summary

Add RedactToolOutput bool to TracingConfig. When set, the tool result body sent to LLMObs is replaced with "[REDACTED]"; the result.IsError flag is still honored for span error status.

This is needed when downstream access controls (e.g. org2-dac in the internal dd-source copy) forbid forwarding tool output to LLMObs traces — partner teams need to see how their tools are being used in the MCP server, but not what those tools returned.

Implements the functionality of PR #429591, which hardcoded the substitution to "[REDACTED]" in the middleware. Here it's a configuration option so the original always-on behavior remains the default for external users.

Test plan

  • TestRedactToolOutput — success case: output is exactly "[REDACTED]" and the actual result body does not leak into span metadata.
  • TestRedactToolOutputStillReportsIsErrormcp.NewToolResultError with redaction enabled still sets error.message on the span; the error detail string does not appear in the output annotation.
  • All existing tracing and intent-capture tests still pass (output redaction defaults to off).

Stacked on #4944.

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Jun 24, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 83.33%
Overall Coverage: 62.78%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e52108e | Docs | Datadog PR Page | Give us feedback!

@pr-commenter

pr-commenter Bot commented Jun 24, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-01 16:47:32

Comparing candidate commit e52108e in PR branch jb/mcp-configurable-tool-output-redaction with baseline commit 2e459f6 in branch jb/mcp-conditional-intent-capture.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 321 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

Known flaky benchmarks without significant changes:

  • scenario:BenchmarkOTLPTraceWriterFlush

Comment thread contrib/mark3labs/mcp-go/tracing.go Outdated
@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from 4304847 to d0520e7 Compare June 24, 2026 14:43
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 3eb1396 to d5512ab Compare June 24, 2026 14:43
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from d5512ab to 7a388f0 Compare June 24, 2026 15:09
@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from d0520e7 to 685d0fd Compare June 24, 2026 15:09
@jboolean jboolean marked this pull request as ready for review June 24, 2026 15:11
@jboolean jboolean requested review from a team as code owners June 24, 2026 15:11
@jboolean jboolean requested review from rarguelloF and removed request for a team June 24, 2026 15:11

@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: 7a388f0236

ℹ️ 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".

//
// The result.IsError flag is still honored for span error status — only
// the output content is redacted.
RedactToolOutput bool

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document the new tracer customization

This adds a public TracingConfig option that changes what LLMObs records for MCP tool calls, but the commit does not update any docs for users to discover or apply it. The root AGENTS.md says CONTRIBUTING.md should be updated for significant features that introduce a new way of interacting with or customizing the tracer, so please document this new redaction knob (or explain why it is intentionally exempt).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full intent-capture and redaction feature set in this stack (#4939#4945) is documented in each TracingConfig field's GoDoc rather than CONTRIBUTING.md, consistent with how the contrib's existing Hooks and IntentCaptureEnabled options are documented today. CONTRIBUTING.md currently has no MCP section to extend; adding one for this knob alone would be inconsistent with the rest of the stack.

@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from 685d0fd to 7e486c3 Compare June 24, 2026 15:28
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 7a388f0 to 077eda1 Compare June 24, 2026 15:28
@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from 7e486c3 to 7a44561 Compare June 24, 2026 16:48
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 077eda1 to 3ee0d24 Compare June 24, 2026 16:48
Comment thread contrib/mark3labs/mcp-go/option.go Outdated
IntentCaptureEnabledFunc func(ctx context.Context) bool
// RedactToolOutput replaces the tool result body sent to LLMObs with a
// fixed "[REDACTED]" string. Use this when downstream access controls
// (e.g. org2-dac) forbid forwarding tool output to LLMObs traces.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a public repo, maybe not use internal jargon like org2-dac? something non-internal like "data access control policies"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — replaced org2-dac with "data access control policies" in 78a7680b8faec88a108b3fcde8dcf36157829300.

@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from 7a44561 to f97103f Compare June 24, 2026 17:29
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 3ee0d24 to e071f3a Compare June 24, 2026 17:29
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from d5629ec to 564721c Compare June 30, 2026 20:59
@jboolean jboolean requested a review from a team as a code owner June 30, 2026 20:59
@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from 910e0f2 to 5deafee Compare July 1, 2026 13:51
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 564721c to 93b8d21 Compare July 1, 2026 14:00
@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from 5deafee to 2e6bb68 Compare July 1, 2026 14:46
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 93b8d21 to 78a7680 Compare July 1, 2026 14:58
@jboolean jboolean force-pushed the jb/mcp-conditional-intent-capture branch from 2e6bb68 to 9036f6d Compare July 1, 2026 15:02
@jboolean jboolean changed the base branch from jb/mcp-conditional-intent-capture to graphite-base/4945 July 1, 2026 16:05
@jboolean jboolean force-pushed the graphite-base/4945 branch from 9036f6d to 952cf50 Compare July 1, 2026 16:12
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 78a7680 to 608922c Compare July 1, 2026 16:12
@jboolean jboolean changed the base branch from graphite-base/4945 to jb/mcp-conditional-intent-capture July 1, 2026 16:12
@jboolean jboolean changed the base branch from jb/mcp-conditional-intent-capture to graphite-base/4945 July 1, 2026 16:17
…bs traces

Add RedactToolOutput bool to TracingConfig. When set, the tool result body
sent to LLMObs is replaced with '[REDACTED]'; the result.IsError flag is
still honored for span error status.

This is needed when downstream access controls (e.g. org2-dac in the
internal dd-source copy) forbid forwarding tool output to LLMObs traces.

Generalizes the hardcoded redaction in internal dd-source PR #429591 into
a configuration option so the original always-on behavior remains the
default for external users.
@jboolean jboolean force-pushed the jb/mcp-configurable-tool-output-redaction branch from 608922c to e52108e Compare July 1, 2026 16:19
@jboolean jboolean force-pushed the graphite-base/4945 branch from 952cf50 to 2e459f6 Compare July 1, 2026 16:19
@jboolean jboolean changed the base branch from graphite-base/4945 to jb/mcp-conditional-intent-capture July 1, 2026 16:19
@jboolean

jboolean commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

/stack merge

@gh-worker-devflow-routing-ef8351

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-02 19:48:47 UTC ℹ️ Start processing command /stack merge
If you need support, contact us on Slack #devflow!


2026-07-02 19:49:05 UTC ℹ️ Devflow: Merging stacked PRs in the following order:

  1. feat(contrib/mark3labs/mcp-go): support intent capture for tools using RawInputSchema (#4939)
  2. fix(contrib/mark3labs/mcp-go): avoid map race when normalizing RawInputSchema (#4940)
  3. fix(contrib/mark3labs/mcp-go): preserve raw input schema fields on intent injection (#4946)
  4. feat(contrib/mark3labs/mcp-go): expose captured intent to tool handlers via context (#4941)
  5. feat(contrib/mark3labs/mcp-go): skip telemetry injection for UI-only tools (#4942)
  6. feat(contrib/mark3labs/mcp-go): set session ID on tool spans at start time (#4943)
  7. feat(contrib/mark3labs/mcp-go): support per-request intent capture (#4944)
  8. feat(contrib/mark3labs/mcp-go): support redacting tool output in LLMObs traces (#4945)

Progress updates will be sent here directly.

If you need support, contact us on Slack #devflow!


2026-07-02 19:49:06 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): support intent capture for tools using RawInputSchema (#4939)...
If you need support, contact us on Slack #devflow!


2026-07-02 19:49:10 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 19m (p90).

If you need support, contact us on Slack #devflow!


2026-07-02 20:04:30 UTC ℹ️ MergeQueue: This merge request was merged
If you need support, contact us on Slack #devflow!


2026-07-02 20:04:35 UTC ℹ️ Devflow: Merging fix(contrib/mark3labs/mcp-go): avoid map race when normalizing RawInputSchema (#4940)...
If you need support, contact us on Slack #devflow!


2026-07-02 20:04:40 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).

If you need support, contact us on Slack #devflow!


2026-07-02 20:21:03 UTC ℹ️ MergeQueue: This merge request was merged
If you need support, contact us on Slack #devflow!


2026-07-02 20:21:08 UTC ℹ️ Devflow: Merging fix(contrib/mark3labs/mcp-go): preserve raw input schema fields on intent injection (#4946)...
If you need support, contact us on Slack #devflow!


2026-07-02 20:21:13 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).

If you need support, contact us on Slack #devflow!


2026-07-02 20:36:40 UTC ℹ️ MergeQueue: This merge request was merged
If you need support, contact us on Slack #devflow!


2026-07-02 20:36:46 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): expose captured intent to tool handlers via context (#4941)...
If you need support, contact us on Slack #devflow!


2026-07-02 20:36:51 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).

If you need support, contact us on Slack #devflow!


2026-07-02 20:52:12 UTC ℹ️ MergeQueue: This merge request was merged
If you need support, contact us on Slack #devflow!


2026-07-02 20:52:16 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): skip telemetry injection for UI-only tools (#4942)...
If you need support, contact us on Slack #devflow!


2026-07-02 20:52:21 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).

If you need support, contact us on Slack #devflow!


2026-07-02 21:08:44 UTCMergeQueue: This merge request is not mergeable, blocked by github

PR can't be merged according to github policy

If you need support, contact us on Slack #devflow with those details!


2026-07-02 21:08:47 UTCDevflow: /stack merge

The following PRs won't be merged. The current stack is:

To get help about command usage, write /stack merge --help

If you need support, contact us on Slack #devflow with those details!

@jboolean

jboolean commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

/stack merge

@gh-worker-devflow-routing-ef8351

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-03 14:01:12 UTC ℹ️ Start processing command /stack merge
If you need support, contact us on Slack #devflow!


2026-07-03 14:01:23 UTC ℹ️ Devflow: Merging stacked PRs in the following order:

  1. feat(contrib/mark3labs/mcp-go): skip telemetry injection for UI-only tools (#4942)
  2. feat(contrib/mark3labs/mcp-go): set session ID on tool spans at start time (#4943)
  3. feat(contrib/mark3labs/mcp-go): support per-request intent capture (#4944)
  4. feat(contrib/mark3labs/mcp-go): support redacting tool output in LLMObs traces (#4945)

Progress updates will be sent here directly.

If you need support, contact us on Slack #devflow!


2026-07-03 14:01:24 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): skip telemetry injection for UI-only tools (#4942)...
If you need support, contact us on Slack #devflow!


2026-07-03 14:01:42 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.

If you need support, contact us on Slack #devflow!


2026-07-03 18:06:19 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

If you need support, contact us on Slack #devflow!


2026-07-03 18:06:22 UTCDevflow: /stack merge

The following PRs won't be merged. The current stack is:

To get help about command usage, write /stack merge --help

If you need support, contact us on Slack #devflow with those details!

@jboolean

jboolean commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

/stack merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 3, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-03 18:50:39 UTC ℹ️ Start processing command /stack merge


2026-07-03 18:50:49 UTC ℹ️ Devflow: Merging stacked PRs in the following order:

  1. feat(contrib/mark3labs/mcp-go): skip telemetry injection for UI-only tools (#4942)
  2. feat(contrib/mark3labs/mcp-go): set session ID on tool spans at start time (#4943)
  3. feat(contrib/mark3labs/mcp-go): support per-request intent capture (#4944)
  4. feat(contrib/mark3labs/mcp-go): support redacting tool output in LLMObs traces (#4945)

Progress updates will be sent here directly.


2026-07-03 18:50:49 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): skip telemetry injection for UI-only tools (#4942)...


2026-07-03 18:51:05 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-07-03 19:14:08 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 19m (p90).


2026-07-03 19:31:30 UTC ℹ️ MergeQueue: This merge request was merged


2026-07-03 19:31:36 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): set session ID on tool spans at start time (#4943)...


2026-07-03 19:31:40 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).


2026-07-03 19:47:09 UTC ℹ️ MergeQueue: This merge request was merged


2026-07-03 19:47:16 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): support per-request intent capture (#4944)...


2026-07-03 19:47:21 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).


2026-07-03 20:02:35 UTC ℹ️ MergeQueue: This merge request was merged


2026-07-03 20:02:40 UTC ℹ️ Devflow: Merging feat(contrib/mark3labs/mcp-go): support redacting tool output in LLMObs traces (#4945)...


2026-07-03 20:02:46 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 18m (p90).


2026-07-03 20:19:01 UTC ℹ️ MergeQueue: This merge request was merged


2026-07-03 20:19:05 UTC ℹ️ Devflow: /stack merge

This stack was merged successfully.

Base automatically changed from jb/mcp-conditional-intent-capture to main July 3, 2026 20:02
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit b0dbe0c into main Jul 3, 2026
308 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the jb/mcp-configurable-tool-output-redaction branch July 3, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants