Skip to content

Add mcp.protocol.version, client operation duration, span target naming, and client span kind - #3757

Merged
ChrisJBurns merged 3 commits into
mainfrom
otel/spec-compliance-s2-s4-s5-s6
Feb 10, 2026
Merged

ChrisJBurns merged 3 commits into
mainfrom
otel/spec-compliance-s2-s4-s5-s6

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Feb 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Four small OTEL MCP semantic conventions compliance fixes, building on #3756:

  • mcp.protocol.version attribute: Read the MCP-Protocol-Version header from streamable HTTP requests and emit as a span attribute per the OTEL MCP semconv.

  • mcp.client.operation.duration metric: Add the spec-defined histogram metric to the vMCP backend client with correct bucket boundaries (MCPHistogramBuckets), alongside the existing toolhive_vmcp_backend_requests_duration custom metric.

  • Span naming with target: Span names now follow the OTEL MCP semconv "{method} {target}" format (e.g., "tools/call github_search" instead of "tools/call").

  • SpanKindClient on backend calls: vMCP backend call spans now use trace.SpanKindClient instead of the default Internal kind, enabling proper distributed trace linking.

Depends on #3756.

Test plan

  • Updated span name tests to expect "{method} {target}" format
  • Updated integration test span name assertion
  • All telemetry and vMCP server tests pass
  • Linter passes with zero issues

🤖 Generated with Claude Code

ChrisJBurns and others added 2 commits February 10, 2026 22:53
- Fix SSE active connections gauge that was incremented but never
  decremented. Move increment into Handler with a defer decrement so
  the gauge correctly tracks SSE connection lifecycle.

- Fix config file `use-legacy-attributes: false` being silently ignored.
  Change UseLegacyAttributes from bool to *bool in app config so nil
  (not set) is distinguishable from explicit false. Add two test cases
  covering both scenarios.

- Log metric creation errors at debug level instead of silently
  discarding them. The OTEL SDK returns no-op instruments on error so
  there is no runtime risk, but logging aids troubleshooting.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ng, and client span kind

- Add mcp.protocol.version span attribute by reading the
  MCP-Protocol-Version header from streamable HTTP requests.

- Add mcp.client.operation.duration histogram metric to vMCP backend
  client using the OTEL MCP semconv bucket boundaries, alongside the
  existing toolhive_vmcp_backend_requests_duration custom metric.

- Include target name in span names per OTEL MCP semconv. Span names
  now follow the "{method} {target}" format, e.g. "tools/call
  github_search" instead of just "tools/call".

- Set SpanKindClient on vMCP backend call spans for proper distributed
  trace linking.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Feb 10, 2026
@ChrisJBurns ChrisJBurns changed the title Add mcp.protocol.version, client operation duration, span target naming, and client span kind Add mcp.protocol.version, client operation duration, span target naming, and client span kind Feb 10, 2026
rdimitrov
rdimitrov previously approved these changes Feb 10, 2026
@codecov

codecov Bot commented Feb 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.42%. Comparing base (cee60fd) to head (79d46bb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/server/telemetry.go 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3757      +/-   ##
==========================================
- Coverage   66.50%   66.42%   -0.09%     
==========================================
  Files         428      428              
  Lines       42069    42084      +15     
==========================================
- Hits        27979    27955      -24     
- Misses      11956    12001      +45     
+ Partials     2134     2128       -6     

☔ View full report in Codecov by Sentry.
📢 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.

Base automatically changed from otel/fix-telemetry-bugs-b1-b2-b4 to main February 10, 2026 23:32
@ChrisJBurns
ChrisJBurns dismissed rdimitrov’s stale review February 10, 2026 23:32

The base branch was changed.

@github-actions github-actions Bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Feb 10, 2026
@ChrisJBurns
ChrisJBurns merged commit 5e2fa08 into main Feb 10, 2026
36 checks passed
@ChrisJBurns
ChrisJBurns deleted the otel/spec-compliance-s2-s4-s5-s6 branch February 10, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants