feat: Add OpenTelemetry distributed tracing support (#263)#264
Merged
feat: Add OpenTelemetry distributed tracing support (#263)#264
Conversation
- Add response.k8s_items_count to track returned items - Add response.text_size_bytes for response size tracking - Add response.content_type for format identification - Add privacy flag OTEL_CAPTURE_RESPONSE_METADATA (default: true) - Add roadmap section for metrics and logs (coming soon) - Maintain simple single-span approach (no nested spans) - 100% backward compatible Closes #263
Flux159
approved these changes
Jan 31, 2026
Owner
Flux159
left a comment
There was a problem hiding this comment.
Code looks fine, just update / answer Qs and then can merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds OpenTelemetry distributed tracing as a new observability feature for the Kubernetes MCP server. This enables comprehensive monitoring of tool executions, performance tracking, and error analysis.
New Feature: OpenTelemetry Integration
What's Added
Captured Telemetry
Request Attributes:
Response Attributes:
response.content_items- Number of content blocksresponse.content_type- Content type (text, json, etc.)response.text_size_bytes- Response size in bytesresponse.k8s_items_count- Number of K8s resources returnedresponse.k8s_kind- Resource kind (PodList, NodeList, etc.)Configuration
Enable Tracing
Optional Controls
Example Trace
{ "spanName": "tools/call kubectl_get", "duration": "1915ms", "attributes": { "gen_ai.tool.name": "kubectl_get", "gen_ai.operation.name": "execute_tool", "k8s.resource_type": "deployments", "k8s.namespace": "default", "tool.duration_ms": 1915, "tool.argument_count": 3, "response.k8s_items_count": 92, "response.text_size_bytes": 16851, "response.content_type": "text" }, "status": "OK" }Benefits
Supported Backends
Testing
Implementation
Files Modified
src/config/telemetry-config.ts- Configuration and SDK initializationsrc/middleware/telemetry-middleware.ts- Automatic instrumentationdocs/OBSERVABILITY.md- Complete documentationBackward Compatibility
✅ 100% backward compatible
Roadmap
Current: Distributed tracing
Coming soon: Metrics and logs
Closes #263