Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions cmd/thv-operator/api/v1alpha1/virtualmcpserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ type VirtualMCPServerSpec struct {
// +kubebuilder:validation:Type=object
PodTemplateSpec *runtime.RawExtension `json:"podTemplateSpec,omitempty"`

// Telemetry configures OpenTelemetry-based observability for the Virtual MCP server
// including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint
// TODO(jerm-dro): migrate to the Config field.
// +optional
Telemetry *TelemetryConfig `json:"telemetry,omitempty"`

// Audit configures audit logging for the Virtual MCP server
// When enabled, audit logs include MCP protocol operations
// TODO(jerm-dro): migrate to the Config field.
Expand Down
5 changes: 0 additions & 5 deletions cmd/thv-operator/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 64 additions & 1 deletion cmd/thv-operator/pkg/vmcpconfig/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/stacklok/toolhive/cmd/thv-operator/pkg/oidc"
"github.com/stacklok/toolhive/cmd/thv-operator/pkg/spectoconfig"
thvjson "github.com/stacklok/toolhive/pkg/json"
"github.com/stacklok/toolhive/pkg/telemetry"
"github.com/stacklok/toolhive/pkg/vmcp/auth/converters"
authtypes "github.com/stacklok/toolhive/pkg/vmcp/auth/types"
vmcpconfig "github.com/stacklok/toolhive/pkg/vmcp/config"
Expand Down Expand Up @@ -124,7 +125,11 @@ func (c *Converter) Convert(
config.Operational = c.convertOperational(ctx, vmcp)
}

config.Telemetry = spectoconfig.ConvertTelemetryConfig(ctx, vmcp.Spec.Telemetry, vmcp.Name)
config.Telemetry = spectoconfig.ConvertTelemetryConfig(
ctx,
telemetryConfigFromEmbedded(vmcp.Spec.Config.Telemetry),
vmcp.Name,
)
config.Audit = spectoconfig.ConvertAuditConfig(ctx, vmcp.Spec.Audit, vmcp.Name)

// Apply operational defaults (fills missing values)
Expand Down Expand Up @@ -910,3 +915,61 @@ func (*Converter) convertOperational(

return operational
}

// telemetryConfigFromEmbedded constructs a v1alpha1.TelemetryConfig from the embedded telemetry.Config.
// This allows reusing ConvertTelemetryConfig which applies all the normalization and defaults.
func telemetryConfigFromEmbedded(cfg *telemetry.Config) *mcpv1alpha1.TelemetryConfig {
if cfg == nil {
return nil
}

// Check if telemetry is actually configured
if cfg.Endpoint == "" && !cfg.EnablePrometheusMetricsPath {
return nil
}

telemetryCfg := &mcpv1alpha1.TelemetryConfig{}

// Build OpenTelemetry config if endpoint is configured
if cfg.Endpoint != "" || cfg.TracingEnabled || cfg.MetricsEnabled {
telemetryCfg.OpenTelemetry = &mcpv1alpha1.OpenTelemetryConfig{
Enabled: cfg.Endpoint != "" || cfg.TracingEnabled || cfg.MetricsEnabled,
Endpoint: cfg.Endpoint,
ServiceName: cfg.ServiceName,
Insecure: cfg.Insecure,
}

// Build tracing config
if cfg.TracingEnabled || cfg.SamplingRate != "" {
telemetryCfg.OpenTelemetry.Tracing = &mcpv1alpha1.OpenTelemetryTracingConfig{
Enabled: cfg.TracingEnabled,
SamplingRate: cfg.SamplingRate,
}
}

// Build metrics config
if cfg.MetricsEnabled {
telemetryCfg.OpenTelemetry.Metrics = &mcpv1alpha1.OpenTelemetryMetricsConfig{
Enabled: cfg.MetricsEnabled,
}
}

// Convert headers from map to slice
if len(cfg.Headers) > 0 {
headers := make([]string, 0, len(cfg.Headers))
for k, v := range cfg.Headers {
headers = append(headers, k+"="+v)
}
telemetryCfg.OpenTelemetry.Headers = headers
}
}

// Build Prometheus config
if cfg.EnablePrometheusMetricsPath {
telemetryCfg.Prometheus = &mcpv1alpha1.PrometheusConfig{
Enabled: cfg.EnablePrometheusMetricsPath,
}
}

return telemetryCfg
}
2 changes: 1 addition & 1 deletion deploy/charts/operator-crds/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: toolhive-operator-crds
description: A Helm chart for installing the ToolHive Operator CRDs into Kubernetes.
type: application
version: 0.0.91
version: 0.0.92
appVersion: "0.0.1"
2 changes: 1 addition & 1 deletion deploy/charts/operator-crds/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ToolHive Operator CRDs Helm Chart

![Version: 0.0.91](https://img.shields.io/badge/Version-0.0.91-informational?style=flat-square)
![Version: 0.0.92](https://img.shields.io/badge/Version-0.0.92-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

A Helm chart for installing the ToolHive Operator CRDs into Kubernetes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,9 @@ spec:
- source
type: object
telemetry:
description: Telemetry configures telemetry settings.
description: |-
Telemetry configures OpenTelemetry-based observability for the Virtual MCP server
including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint.
properties:
customAttributes:
additionalProperties:
Expand Down Expand Up @@ -1090,16 +1092,9 @@ spec:
When false, no tracer provider is created even if an endpoint is configured
type: boolean
required:
- enablePrometheusMetricsPath
- endpoint
- environmentVariables
- headers
- insecure
- metricsEnabled
- samplingRate
- serviceName
- serviceVersion
- tracingEnabled
type: object
required:
- groupRef
Expand Down Expand Up @@ -1487,73 +1482,6 @@ spec:
- NodePort
- LoadBalancer
type: string
telemetry:
description: |-
Telemetry configures OpenTelemetry-based observability for the Virtual MCP server
including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint
properties:
openTelemetry:
description: OpenTelemetry defines OpenTelemetry configuration
properties:
enabled:
default: false
description: Enabled controls whether OpenTelemetry is enabled
type: boolean
endpoint:
description: Endpoint is the OTLP endpoint URL for tracing
and metrics
type: string
headers:
description: |-
Headers contains authentication headers for the OTLP endpoint
Specified as key=value pairs
items:
type: string
type: array
insecure:
default: false
description: Insecure indicates whether to use HTTP instead
of HTTPS for the OTLP endpoint
type: boolean
metrics:
description: Metrics defines OpenTelemetry metrics-specific
configuration
properties:
enabled:
default: false
description: Enabled controls whether OTLP metrics are
sent
type: boolean
type: object
serviceName:
description: |-
ServiceName is the service name for telemetry
If not specified, defaults to the MCPServer name
type: string
tracing:
description: Tracing defines OpenTelemetry tracing configuration
properties:
enabled:
default: false
description: Enabled controls whether OTLP tracing is
sent
type: boolean
samplingRate:
default: "0.05"
description: SamplingRate is the trace sampling rate (0.0-1.0)
type: string
type: object
type: object
prometheus:
description: Prometheus defines Prometheus-specific configuration
properties:
enabled:
default: false
description: Enabled controls whether Prometheus metrics endpoint
is exposed
type: boolean
type: object
type: object
required:
- incomingAuth
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,9 @@ spec:
- source
type: object
telemetry:
description: Telemetry configures telemetry settings.
description: |-
Telemetry configures OpenTelemetry-based observability for the Virtual MCP server
including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint.
properties:
customAttributes:
additionalProperties:
Expand Down Expand Up @@ -1093,16 +1095,9 @@ spec:
When false, no tracer provider is created even if an endpoint is configured
type: boolean
required:
- enablePrometheusMetricsPath
- endpoint
- environmentVariables
- headers
- insecure
- metricsEnabled
- samplingRate
- serviceName
- serviceVersion
- tracingEnabled
type: object
required:
- groupRef
Expand Down Expand Up @@ -1490,73 +1485,6 @@ spec:
- NodePort
- LoadBalancer
type: string
telemetry:
description: |-
Telemetry configures OpenTelemetry-based observability for the Virtual MCP server
including distributed tracing, OTLP metrics export, and Prometheus metrics endpoint
properties:
openTelemetry:
description: OpenTelemetry defines OpenTelemetry configuration
properties:
enabled:
default: false
description: Enabled controls whether OpenTelemetry is enabled
type: boolean
endpoint:
description: Endpoint is the OTLP endpoint URL for tracing
and metrics
type: string
headers:
description: |-
Headers contains authentication headers for the OTLP endpoint
Specified as key=value pairs
items:
type: string
type: array
insecure:
default: false
description: Insecure indicates whether to use HTTP instead
of HTTPS for the OTLP endpoint
type: boolean
metrics:
description: Metrics defines OpenTelemetry metrics-specific
configuration
properties:
enabled:
default: false
description: Enabled controls whether OTLP metrics are
sent
type: boolean
type: object
serviceName:
description: |-
ServiceName is the service name for telemetry
If not specified, defaults to the MCPServer name
type: string
tracing:
description: Tracing defines OpenTelemetry tracing configuration
properties:
enabled:
default: false
description: Enabled controls whether OTLP tracing is
sent
type: boolean
samplingRate:
default: "0.05"
description: SamplingRate is the trace sampling rate (0.0-1.0)
type: string
type: object
type: object
prometheus:
description: Prometheus defines Prometheus-specific configuration
properties:
enabled:
default: false
description: Enabled controls whether Prometheus metrics endpoint
is exposed
type: boolean
type: object
type: object
required:
- incomingAuth
type: object
Expand Down
2 changes: 0 additions & 2 deletions docs/operator/crd-api.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading