Skip to content

Fix MCP tool call attribute selection#2518

Open
MrAlias wants to merge 2 commits into
open-telemetry:mainfrom
MrAlias:mcp-tool-payload-attr-select
Open

Fix MCP tool call attribute selection#2518
MrAlias wants to merge 2 commits into
open-telemetry:mainfrom
MrAlias:mcp-tool-payload-attr-select

Conversation

@MrAlias

@MrAlias MrAlias commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • A recent change captured MCP tool-call arguments and results but these sensitive payloads were gated by broad GenAI input/output selection, preventing operators from independently including or excluding gen_ai.tool.call.arguments and gen_ai.tool.call.result.
  • The goal is to restore per-attribute control so tool-call payloads cannot be exported implicitly when operators opt into other GenAI data.

Description

  • Add attr.GenAIToolCallArguments and attr.GenAIToolCallResult to the trace attribute selector definitions so they appear in attributes.select configuration (pkg/export/attributes/attr_defs.go).
  • Change MCP span emission to gate tool-call arguments/results on their own optional attribute names instead of GenAIInput/GenAIOutput (pkg/export/otel/tracesgen/tracesgen.go).
  • Add selector tests to verify inclusion/exclusion behavior for gen_ai.tool.call.* (pkg/export/attributes/attr_selector_test.go).
  • Add trace tests to ensure gen_ai.tool.call.arguments/gen_ai.tool.call.result are not emitted via GenAIInput/GenAIOutput and are emitted when their own selectors are enabled (pkg/export/otel/tracesgen/tracesgen_test.go).

Testing

  • go test ./pkg/export/attributes ./pkg/export/otel/tracesgen

@MrAlias MrAlias requested a review from a team as a code owner June 26, 2026 16:43
@MrAlias MrAlias added go Related to Go code area: tracing Trace context, span construction, and trace attribute behavior labels Jun 26, 2026
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.18%. Comparing base (914ffa4) to head (8c337e2).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/export/attributes/attr_select.go 83.33% 1 Missing ⚠️
pkg/export/attributes/attr_selector.go 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2518      +/-   ##
==========================================
- Coverage   69.24%   69.18%   -0.07%     
==========================================
  Files         345      345              
  Lines       46747    46811      +64     
==========================================
+ Hits        32372    32384      +12     
- Misses      12330    12394      +64     
+ Partials     2045     2033      -12     
Flag Coverage Δ
integration-test 50.66% <70.83%> (-0.26%) ⬇️
integration-test-arm 27.13% <66.66%> (-1.18%) ⬇️
integration-test-vm-5.15-lts ?
integration-test-vm-6.18-lts ?
k8s-integration-test 36.04% <70.83%> (+0.34%) ⬆️
oats-test 35.38% <70.83%> (+0.01%) ⬆️
unittests 63.40% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Compare MCP tool-call payload attributes as JSON so testifylint accepts the trace selector test. The assertions still verify the emitted payloads while avoiding direct encoded-string comparisons.

@grcevski grcevski 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.

LGTM! Looks great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tracing Trace context, span construction, and trace attribute behavior go Related to Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants