|
| 1 | +--- |
| 2 | +title: Observability |
| 3 | +description: |
| 4 | + How to enable OpenTelemetry traces and metrics for Virtual MCP Server. |
| 5 | +--- |
| 6 | + |
| 7 | +Virtual MCP Server (vMCP) provides comprehensive observability through |
| 8 | +OpenTelemetry instrumentation. You can export traces and metrics to monitor |
| 9 | +backend operations and workflow executions. |
| 10 | + |
| 11 | +## Telemetry types |
| 12 | + |
| 13 | +vMCP supports two types of telemetry: |
| 14 | + |
| 15 | +- **Traces**: Track requests across vMCP and its backends, showing the full path |
| 16 | + of tool calls, resource reads, and workflow executions |
| 17 | +- **Metrics**: Counters and histograms for backend request rates, error rates, |
| 18 | + and latency distributions |
| 19 | + |
| 20 | +For general ToolHive observability concepts including trace structure and |
| 21 | +metrics, see the [observability overview](../concepts/observability.mdx). |
| 22 | + |
| 23 | +## Enable telemetry |
| 24 | + |
| 25 | +Configure telemetry in the VirtualMCPServer resource using the |
| 26 | +`spec.config.telemetry` field: |
| 27 | + |
| 28 | +```yaml |
| 29 | +apiVersion: toolhive.stacklok.dev/v1alpha1 |
| 30 | +kind: VirtualMCPServer |
| 31 | +metadata: |
| 32 | + name: my-vmcp |
| 33 | + namespace: toolhive-system |
| 34 | +spec: |
| 35 | + config: |
| 36 | + groupRef: my-group |
| 37 | + # highlight-start |
| 38 | + telemetry: |
| 39 | + endpoint: 'otel-collector:4317' |
| 40 | + serviceName: 'my-vmcp' |
| 41 | + insecure: true |
| 42 | + tracingEnabled: true |
| 43 | + samplingRate: '0.1' |
| 44 | + metricsEnabled: true |
| 45 | + enablePrometheusMetricsPath: true |
| 46 | + # highlight-end |
| 47 | + incomingAuth: |
| 48 | + type: anonymous |
| 49 | +``` |
| 50 | +
|
| 51 | +### Configuration options |
| 52 | +
|
| 53 | +| Field | Description | Default | |
| 54 | +| ----------------------------- | --------------------------------------- | --------------------- | |
| 55 | +| `endpoint` | OTLP collector endpoint (hostname:port) | - | |
| 56 | +| `serviceName` | Service name in traces and metrics | VirtualMCPServer name | |
| 57 | +| `tracingEnabled` | Enable tracing | `false` | |
| 58 | +| `metricsEnabled` | Enable OTLP metrics export | `false` | |
| 59 | +| `samplingRate` | Trace sampling rate (0.0-1.0) | `"0.05"` | |
| 60 | +| `insecure` | Use HTTP instead of HTTPS | `false` | |
| 61 | +| `enablePrometheusMetricsPath` | Expose `/metrics` endpoint | `false` | |
| 62 | + |
| 63 | +## Export to observability backends |
| 64 | + |
| 65 | +### Export to Jaeger via OpenTelemetry Collector |
| 66 | + |
| 67 | +Deploy an OpenTelemetry Collector configured to export to Jaeger: |
| 68 | + |
| 69 | +```yaml title="otel-collector-config.yaml" |
| 70 | +config: |
| 71 | + receivers: |
| 72 | + otlp: |
| 73 | + protocols: |
| 74 | + grpc: |
| 75 | + endpoint: 0.0.0.0:4317 |
| 76 | + http: |
| 77 | + endpoint: 0.0.0.0:4318 |
| 78 | +
|
| 79 | + exporters: |
| 80 | + otlp/jaeger: |
| 81 | + endpoint: http://jaeger-collector:4317 |
| 82 | +
|
| 83 | + service: |
| 84 | + pipelines: |
| 85 | + traces: |
| 86 | + receivers: [otlp] |
| 87 | + processors: [batch] |
| 88 | + exporters: [otlp/jaeger] |
| 89 | + metrics: |
| 90 | + receivers: [otlp] |
| 91 | + processors: [batch] |
| 92 | + exporters: [prometheus] |
| 93 | +``` |
| 94 | + |
| 95 | +Then configure vMCP to send telemetry to the collector: |
| 96 | + |
| 97 | +```yaml |
| 98 | +spec: |
| 99 | + config: |
| 100 | + telemetry: |
| 101 | + endpoint: 'otel-collector:4317' |
| 102 | + serviceName: 'production-vmcp' |
| 103 | + tracingEnabled: true |
| 104 | + metricsEnabled: true |
| 105 | + insecure: true |
| 106 | +``` |
| 107 | + |
| 108 | +## Prometheus metrics |
| 109 | + |
| 110 | +Enable Prometheus scraping by setting `enablePrometheusMetricsPath: true`. |
| 111 | +Metrics are exposed on the vMCP service port (4483) at `/metrics`. |
| 112 | + |
| 113 | +## Related information |
| 114 | + |
| 115 | +- [Observability concepts](../concepts/observability.mdx) - Overview of |
| 116 | + ToolHive's observability architecture |
| 117 | +- [Kubernetes telemetry guide](../guides-k8s/telemetry-and-metrics.mdx) - |
| 118 | + Telemetry for MCPServer resources |
| 119 | +- [OpenTelemetry tutorial](../tutorials/opentelemetry.mdx) - Set up a local |
| 120 | + observability stack |
0 commit comments