Repository navigation
Labels
Description
Description
Create the MCPTelemetryConfig CRD type definitions using a nested structure with openTelemetry and prometheus sub-objects, as specified in RFC THV-0023.
Why nested instead of flat?
The original implementation used inline embedding of telemetry.Config which exposed CLI-only fields (environmentVariables) and per-server fields (serviceName) in the CRD spec. The RFC specifies a nested structure that:
- Groups OTLP settings under
spec.openTelemetry(endpoint, headers, tracing, metrics) - Groups Prometheus settings under
spec.prometheus - Excludes
serviceName(per-server, set viaMCPTelemetryConfigReference) - Excludes
environmentVariablesandcustomAttributes(CLI-only) - Uses
resourceAttributesinstead ofcustomAttributesfor OTel resource attributes
Target Structure
apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPTelemetryConfig
metadata:
name: production-telemetry
namespace: mcp-platform
spec:
openTelemetry:
enabled: true
endpoint: otel-collector.monitoring.svc.cluster.local:4318
insecure: false
sensitiveHeaders:
- name: Authorization
secretKeyRef:
name: otel-auth-secret
key: bearer-token
- name: X-API-Key
secretKeyRef:
name: otel-secret
key: api-key
resourceAttributes:
service.namespace: toolhive
deployment.environment: production
metrics:
enabled: true
tracing:
enabled: true
samplingRate: "0.1"
useLegacyAttributes: true
prometheus:
enabled: true
status:
observedGeneration: 1
configHash: "sha256:..."
referencingWorkloads:
- kind: MCPServer
name: server-a
conditions:
- type: Valid
status: "True"Go Types
type MCPTelemetryConfigSpec struct {
OpenTelemetry *MCPTelemetryOTelConfig `json:"openTelemetry,omitempty"`
Prometheus *PrometheusConfig `json:"prometheus,omitempty"`
}
type MCPTelemetryOTelConfig struct {
Enabled bool `json:"enabled,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
Insecure bool `json:"insecure,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
SensitiveHeaders []SensitiveHeader `json:"sensitiveHeaders,omitempty"`
ResourceAttributes map[string]string `json:"resourceAttributes,omitempty"`
Metrics *OpenTelemetryMetricsConfig `json:"metrics,omitempty"`
Tracing *OpenTelemetryTracingConfig `json:"tracing,omitempty"`
UseLegacyAttributes bool `json:"useLegacyAttributes"`
}
type MCPTelemetryConfigStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
ConfigHash string `json:"configHash,omitempty"`
ReferencingWorkloads []WorkloadReference `json:"referencingWorkloads,omitempty"`
}
// WorkloadReference is shared across CRDs (defined in mcpoidcconfig_types.go)
type WorkloadReference struct {
Kind string `json:"kind"` // MCPServer, VirtualMCPServer, MCPRemoteProxy
Name string `json:"name"`
}Key Design Decisions
Headersismap[string]stringfor non-sensitive headers (e.g.,X-Custom-Tag: value). Credential headers (bearer tokens, API keys) should usesensitiveHeaderswithSecretKeyRefinstead.SensitiveHeadersusesSecretKeyReffor credential headers (no inline secrets)ResourceAttributesreplacescustomAttributes— maps totelemetry.Config.CustomAttributesat runtimeServiceNameexcluded from shared config — it is per-server viaMCPTelemetryConfigReferenceWorkloadReferenceis a shared type (defined inmcpoidcconfig_types.go) withKind+Name— namespace is implicit since cross-namespace refs are not supported- Conversion from CRD nested types to flat
telemetry.Configis handled byspectoconfig.NormalizeMCPTelemetryConfig
Phase 2 Fields (not yet implemented)
These RFC fields require runtime support and will be added in follow-up PRs:
spec.openTelemetry.protocol(http/grpc) — needs gRPC exporter supportspec.openTelemetry.metrics.exportInterval— needssdkmetric.WithInterval()spec.openTelemetry.tracing.propagators— needs dynamic propagator factoryspec.prometheus.path— hardcoded to/metricsspec.prometheus.port— shares transport port
Acceptance Criteria
-
MCPTelemetryConfigSpecuses nestedopenTelemetry/prometheusstructure matching RFC THV-0023 -
Headersismap[string]string -
SensitiveHeadersusesSecretKeyReffor credential headers -
ResourceAttributesfield for shared OTel resource attributes -
ServiceNameexcluded from shared config (per-server field) -
ReferencingWorkloadsuses sharedWorkloadReferencetype (Kind + Name) - Conversion layer (
spectoconfig.NormalizeMCPTelemetryConfig) maps nested CRD to flattelemetry.Config -
task operator-generateandtask operator-manifestssucceed - Unit tests verify type structure and conversion correctness
- Tests pass (
task test)
Activity
Restructure MCPTelemetryConfig CRD to nested spec per RFC THV-0023
Restructure MCPTelemetryConfig CRD to nested spec per RFC THV-0023
Restructure MCPTelemetryConfig CRD to nested spec per RFC THV-0023
Restructure MCPTelemetryConfig CRD to nested spec per RFC THV-0023 (s…