Instrument vMCP and Document o11y Configuration#2906
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2906 +/- ##
==========================================
- Coverage 56.30% 56.00% -0.30%
==========================================
Files 324 325 +1
Lines 31921 32091 +170
==========================================
+ Hits 17972 17974 +2
- Misses 12412 12576 +164
- Partials 1537 1541 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive observability to the Virtual MCP Server (vMCP) by integrating OpenTelemetry-based metrics and distributed tracing. The implementation uses a decorator pattern to instrument both backend client operations and composite workflow executions, providing visibility into the vMCP's operations without modifying core business logic.
Key Changes:
- Implemented telemetry instrumentation using decorator pattern for backend clients and workflow executors
- Added OpenTelemetry configuration to VirtualMCPServer CRD with pass-through to vMCP config
- Created dedicated observability documentation for vMCP with configuration examples
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/vmcp/server/telemetry.go | New file implementing telemetry decorators for backend clients and workflow executors using OpenTelemetry metrics and traces |
| pkg/vmcp/server/server.go | Integrates telemetry provider, decorates backend client and workflow executors, adds /metrics endpoint and telemetry middleware |
| pkg/vmcp/config/config.go | Adds Telemetry field to vMCP configuration structure |
| test/integration/vmcp/vmcp_integration_test.go | Adds integration test verifying metrics emission for workflows and backend calls |
| test/integration/vmcp/helpers/vmcp_server.go | Extends test helper with workflow definitions and telemetry provider support |
| pkg/telemetry/middleware.go | Documentation update for transport types |
| pkg/telemetry/config.go | Documentation update for transport types |
| examples/vmcp-config.yaml | Adds telemetry configuration example |
| docs/operator/virtualmcpserver-observability.md | New documentation describing vMCP observability features and configuration |
| docs/operator/virtualmcpserver-api.md | Documents spec.telemetry field in VirtualMCPServer CRD |
| docs/observability.md | Links to vMCP-specific observability documentation |
| cmd/vmcp/app/commands.go | Creates telemetry provider from config and passes to server |
| cmd/vmcp/README.md | Updates feature list to include observability |
| cmd/thv-operator/pkg/vmcpconfig/converter.go | Passes through telemetry config from CRD to vMCP config |
| cmd/thv-operator/api/v1alpha1/virtualmcpserver_types.go | Adds Telemetry field to VirtualMCPServerSpec |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
jhrozek
left a comment
There was a problem hiding this comment.
I would recommend pinging @ChrisJBurns about the metrics as he has pretty good experience implementing metrics for MCPServer but also as an SRE. I added some code questions inline, chiefly the one about the CRD types.
bc6a030 to
69d88ce
Compare
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
3f939a5 to
931bbde
Compare
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
c9b6f53 to
105cd92
Compare
Summary
This PR adds metrics and distributed tracing to the Virtual MCP Server (vMCP), providing visibility into backend calls and composite workflow executions.
Fixes #2849
Large PR Justification
This is a fairly large PR, but most of it is documentation which I thought would be easier to review if it was included with the code changes.
Changes
Implementation
telemetry.gowith decorator pattern for instrumenting backend clients and workflow executorsMetrics Emitted
toolhive_vmcp_backends_discovered- Number of backends discoveredtoolhive_vmcp_backend_requests- Request count per backendtoolhive_vmcp_backend_errors- Error count per backendtoolhive_vmcp_backend_requests_duration- Request duration histogramtoolhive_vmcp_workflow_executionsl- Workflow execution counttoolhive_vmcp_workflow_errors- Workflow error counttoolhive_vmcp_workflow_duration- Workflow duration histogramCRD Updates
spec.telemetryfield to VirtualMCPServer for configuring OpenTelemetry and PrometheusDocumentation
docs/operator/virtualmcpserver-observability.md)spec.telemetryfield in VirtualMCPServer API referencedocs/observability.mdwith link to vMCP observabilityexamples/vmcp-config.yamlandcmd/vmcp/README.mdTesting