Skip to content

Commit 11127e2

Browse files
committed
vMCP CRD uses common spec telemetry type
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
1 parent 67acde4 commit 11127e2

7 files changed

Lines changed: 130 additions & 40 deletions

File tree

cmd/thv-operator/api/v1alpha1/virtualmcpserver_types.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package v1alpha1
33
import (
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
55
"k8s.io/apimachinery/pkg/runtime"
6-
7-
"github.com/stacklok/toolhive/pkg/telemetry"
86
)
97

108
// VirtualMCPServerSpec defines the desired state of VirtualMCPServer
@@ -60,7 +58,7 @@ type VirtualMCPServerSpec struct {
6058
// Telemetry configures OpenTelemetry-based observability for the Virtual MCP server
6159
// including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint
6260
// +optional
63-
Telemetry *telemetry.Config `json:"telemetry,omitempty"`
61+
Telemetry *TelemetryConfig `json:"telemetry,omitempty"`
6462
}
6563

6664
// GroupRef references an MCPGroup resource

cmd/thv-operator/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/thv-operator/pkg/vmcpconfig/converter.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
mcpv1alpha1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1alpha1"
1717
"github.com/stacklok/toolhive/cmd/thv-operator/pkg/oidc"
18+
"github.com/stacklok/toolhive/cmd/thv-operator/pkg/spectoconfig"
1819
authtypes "github.com/stacklok/toolhive/pkg/vmcp/auth/types"
1920
vmcpconfig "github.com/stacklok/toolhive/pkg/vmcp/config"
2021
)
@@ -110,9 +111,7 @@ func (c *Converter) Convert(
110111
config.Operational = c.convertOperational(ctx, vmcp)
111112
}
112113

113-
// Convert Telemetry - pass through directly as it's the same type.
114-
// Eventually, we may want to decouple the two, but for now this is fine.
115-
config.Telemetry = vmcp.Spec.Telemetry
114+
config.Telemetry = spectoconfig.ConvertTelemetryConfig(ctx, vmcp.Spec.Telemetry, vmcp.Name)
116115

117116
// Apply operational defaults (fills missing values)
118117
config.EnsureOperationalDefaults()

deploy/charts/operator-crds/crds/toolhive.stacklok.dev_virtualmcpservers.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,73 @@ spec:
733733
- NodePort
734734
- LoadBalancer
735735
type: string
736+
telemetry:
737+
description: |-
738+
Telemetry configures OpenTelemetry-based observability for the Virtual MCP server
739+
including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint
740+
properties:
741+
openTelemetry:
742+
description: OpenTelemetry defines OpenTelemetry configuration
743+
properties:
744+
enabled:
745+
default: false
746+
description: Enabled controls whether OpenTelemetry is enabled
747+
type: boolean
748+
endpoint:
749+
description: Endpoint is the OTLP endpoint URL for tracing
750+
and metrics
751+
type: string
752+
headers:
753+
description: |-
754+
Headers contains authentication headers for the OTLP endpoint
755+
Specified as key=value pairs
756+
items:
757+
type: string
758+
type: array
759+
insecure:
760+
default: false
761+
description: Insecure indicates whether to use HTTP instead
762+
of HTTPS for the OTLP endpoint
763+
type: boolean
764+
metrics:
765+
description: Metrics defines OpenTelemetry metrics-specific
766+
configuration
767+
properties:
768+
enabled:
769+
default: false
770+
description: Enabled controls whether OTLP metrics are
771+
sent
772+
type: boolean
773+
type: object
774+
serviceName:
775+
description: |-
776+
ServiceName is the service name for telemetry
777+
If not specified, defaults to the MCPServer name
778+
type: string
779+
tracing:
780+
description: Tracing defines OpenTelemetry tracing configuration
781+
properties:
782+
enabled:
783+
default: false
784+
description: Enabled controls whether OTLP tracing is
785+
sent
786+
type: boolean
787+
samplingRate:
788+
default: "0.05"
789+
description: SamplingRate is the trace sampling rate (0.0-1.0)
790+
type: string
791+
type: object
792+
type: object
793+
prometheus:
794+
description: Prometheus defines Prometheus-specific configuration
795+
properties:
796+
enabled:
797+
default: false
798+
description: Enabled controls whether Prometheus metrics endpoint
799+
is exposed
800+
type: boolean
801+
type: object
802+
type: object
736803
required:
737804
- groupRef
738805
- incomingAuth

docs/operator/crd-api.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/operator/virtualmcpserver-api.md

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -292,34 +292,41 @@ spec:
292292

293293
### `.spec.telemetry` (optional)
294294

295-
Configures OpenTelemetry-based observability for the Virtual MCP server, including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint.
295+
Configures OpenTelemetry-based observability for the Virtual MCP server, including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint. Uses the same configuration structure as `MCPServer.spec.telemetry`.
296296

297-
**Type**: `telemetry.Config`
297+
**Type**: `TelemetryConfig`
298298

299299
**Fields**:
300-
- `endpoint` (string): OTLP collector endpoint (host:port format)
301-
- `serviceName` (string): Service name for telemetry
302-
- `serviceVersion` (string): Service version for telemetry
303-
- `tracingEnabled` (boolean): Enable distributed tracing
304-
- `metricsEnabled` (boolean): Enable OTLP metrics export
305-
- `samplingRate` (float64): Trace sampling rate (0.0-1.0)
306-
- `headers` (map[string]string): Authentication headers for OTLP endpoint
307-
- `insecure` (boolean): Use HTTP instead of HTTPS
308-
- `enablePrometheusMetricsPath` (boolean): Expose Prometheus /metrics endpoint
309-
- `environmentVariables` ([]string): Environment variable names to include as span attributes
310-
- `customAttributes` (map[string]string): Custom resource attributes for all telemetry signals
300+
- `openTelemetry` (OpenTelemetryConfig, optional): OpenTelemetry configuration
301+
- `enabled` (boolean): Controls whether OpenTelemetry is enabled
302+
- `endpoint` (string): OTLP endpoint URL for tracing and metrics
303+
- `serviceName` (string): Service name for telemetry (defaults to VirtualMCPServer name)
304+
- `headers` ([]string): Authentication headers for OTLP endpoint (key=value format)
305+
- `insecure` (boolean): Use HTTP instead of HTTPS for the OTLP endpoint
306+
- `metrics` (OpenTelemetryMetricsConfig, optional): Metrics-specific configuration
307+
- `enabled` (boolean): Controls whether OTLP metrics are sent
308+
- `tracing` (OpenTelemetryTracingConfig, optional): Tracing-specific configuration
309+
- `enabled` (boolean): Controls whether OTLP tracing is sent
310+
- `samplingRate` (string): Trace sampling rate (0.0-1.0, default: "0.05")
311+
- `prometheus` (PrometheusConfig, optional): Prometheus-specific configuration
312+
- `enabled` (boolean): Controls whether Prometheus metrics endpoint is exposed at /metrics
311313

312314
**Example**:
313315
```yaml
314316
spec:
315317
telemetry:
316-
endpoint: "otel-collector:4317"
317-
serviceName: "my-vmcp"
318-
tracingEnabled: true
319-
metricsEnabled: true
320-
samplingRate: 0.1
321-
insecure: true
322-
enablePrometheusMetricsPath: true
318+
openTelemetry:
319+
enabled: true
320+
endpoint: "otel-collector:4317"
321+
serviceName: "my-vmcp"
322+
insecure: true
323+
tracing:
324+
enabled: true
325+
samplingRate: "0.1"
326+
metrics:
327+
enabled: true
328+
prometheus:
329+
enabled: true
323330
```
324331

325332
For details on what metrics and traces are emitted, see the [Virtual MCP Server Observability](./virtualmcpserver-observability.md) documentation.
@@ -487,11 +494,16 @@ spec:
487494
488495
# Observability
489496
telemetry:
490-
endpoint: "otel-collector:4317"
491-
tracingEnabled: true
492-
metricsEnabled: true
493-
samplingRate: 0.1
494-
enablePrometheusMetricsPath: true
497+
openTelemetry:
498+
enabled: true
499+
endpoint: "otel-collector:4317"
500+
tracing:
501+
enabled: true
502+
samplingRate: "0.1"
503+
metrics:
504+
enabled: true
505+
prometheus:
506+
enabled: true
495507
496508
status:
497509
phase: Ready

docs/operator/virtualmcpserver-observability.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ The vMCP creates spans for each individual backend operation as well as workflow
4545
## Configuration
4646

4747
Configure telemetry in the `VirtualMCPServer` resource using the `spec.telemetry`
48-
field:
48+
field. The telemetry configuration uses the same `TelemetryConfig` type as
49+
`MCPServer`, providing a consistent configuration experience across resources.
4950

5051
```yaml
5152
apiVersion: toolhive.stacklok.dev/v1alpha1
@@ -55,14 +56,21 @@ metadata:
5556
spec:
5657
groupRef:
5758
name: my-group
59+
incomingAuth:
60+
type: anonymous
5861
telemetry:
59-
endpoint: "otel-collector:4317"
60-
serviceName: "my-vmcp"
61-
tracingEnabled: true
62-
metricsEnabled: true
63-
samplingRate: 0.1
64-
insecure: true
65-
enablePrometheusMetricsPath: true
62+
openTelemetry:
63+
enabled: true
64+
endpoint: "otel-collector:4317"
65+
serviceName: "my-vmcp"
66+
insecure: true
67+
tracing:
68+
enabled: true
69+
samplingRate: "0.1"
70+
metrics:
71+
enabled: true
72+
prometheus:
73+
enabled: true
6674
```
6775
6876
See the [VirtualMCPServer API reference](./virtualmcpserver-api.md) for complete

0 commit comments

Comments
 (0)