OTEL: Add error.type and rpc.response.status_code for JSON-RPC errors
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 300
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 184
Description
Context
Identified during the OTEL MCP semantic conventions review (parent issue: #3399). These two spec gaps are related and should be implemented together since they both require the same response-body inspection approach.
error.type missing for JSON-RPC errors and tool_error
Severity: Medium
File: pkg/telemetry/middleware.go
error.type is only set for HTTP 5xx errors. JSON-RPC errors returned in HTTP 200 responses (e.g., -32601) and failed CallToolResult ("tool_error") are invisible to telemetry. This is acknowledged in code comments as future work.
Fix: Would require response body inspection — buffer/parse the JSON-RPC response to detect error codes and tool errors.
Missing rpc.response.status_code for JSON-RPC errors
Severity: Low
File: pkg/telemetry/middleware.go
The OTEL RPC semconv includes rpc.response.status_code for error responses. Would require response body parsing for JSON-RPC error codes.
Fix: Same response-body inspection approach as above.
Implementation considerations
- Both require intercepting/buffering the response body before it's written to the client
- Need to parse JSON-RPC response to extract error codes (e.g.,
-32601,-32602) andCallToolResult.isError - A
tee-style response writer that captures the body while still streaming to the client would be one approach - Should set
error.typeto the JSON-RPC error code string (e.g.,"-32601") or"tool_error"for failed tool calls - High value for observability — currently JSON-RPC errors are invisible in telemetry since they return HTTP 200
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading pkg/telemetry/middleware.go, including its comments and current response handling. Trace how JSON-RPC responses and CallToolResult values can be inspected, then verify that JSON-RPC error codes and tool_error produce error.type and rpc.response.status_code while HTTP 200 responses remain available to clients.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100