Skip to content

Remove deprecated inline telemetry field from CRDs#4819

Merged
ChrisJBurns merged 6 commits intomainfrom
remove-deprecated-inline-telemetry
Apr 14, 2026
Merged

Remove deprecated inline telemetry field from CRDs#4819
ChrisJBurns merged 6 commits intomainfrom
remove-deprecated-inline-telemetry

Conversation

@ChrisJBurns
Copy link
Copy Markdown
Collaborator

@ChrisJBurns ChrisJBurns commented Apr 14, 2026

Summary

The inline telemetry field on MCPServerSpec and MCPRemoteProxySpec was deprecated in favor of telemetryConfigRef, which references a shared MCPTelemetryConfig resource. Similarly, the config.telemetry/telemetryConfigRef mutual-exclusivity CEL rule on VirtualMCPServer existed only to bridge the migration period. This removes all backward-compatibility shim code, CEL rules, deprecated utility functions, and the TelemetryConfig/OpenTelemetryConfig CRD types ahead of the v1beta1 API promotion.

Additionally, the operator-side converter no longer falls back to config.telemetry for VirtualMCPServer (D4). Operator-managed vMCPs must use telemetryConfigRef.

Changes
File Change
api/v1alpha1/mcpserver_types.go Remove Telemetry field, CEL rule, TelemetryConfig/OpenTelemetryConfig types; keep shared sub-types
api/v1alpha1/mcpremoteproxy_types.go Remove Telemetry field, CEL rule
api/v1alpha1/virtualmcpserver_types.go Remove CEL rule for config.telemetry/telemetryConfigRef
controllers/mcpserver_runconfig.go Remove else branch calling deprecated AddTelemetryConfigOptions
controllers/mcpserver_controller.go Remove 2 deprecated env var generation paths
controllers/mcpremoteproxy_runconfig.go Simplify addTelemetryOptions to only handle TelemetryConfigRef
controllers/mcpremoteproxy_deployment.go Remove deprecated inline telemetry env var path
pkg/runconfig/telemetry.go Remove AddTelemetryConfigOptions function
pkg/spectoconfig/telemetry.go Remove ConvertTelemetryConfig function
pkg/controllerutil/tokenexchange.go Remove GenerateOpenTelemetryEnvVars function
pkg/vmcpconfig/converter.go Remove deprecated inline fallback in normalizeTelemetry; operator now returns nil when TelemetryConfigRef is not set
pkg/export/k8s.go Remove inline telemetry export (requires separate MCPTelemetryConfig now)
cmd/thv/app/export.go Add stderr warning when telemetry config is detected during export
*_test.go, test-integration/ Remove/update all tests for deprecated code paths
deploy/charts/operator-crds/ Regenerated CRD YAML (inline telemetry schema removed)

Type of change

  • Refactoring (no behavior change)

Test plan

  • Unit tests (task operator-test)
  • Linting (task lint-fix)
  • Build (go build ./...)

Does this introduce a user-facing change?

Yes — this is a breaking change for existing CRs. See migration guide below.

Migration guide

MCPServer and MCPRemoteProxy

Before (inline telemetry — no longer supported):

spec:
  telemetry:
    openTelemetry:
      enabled: true
      endpoint: "otel-collector:4317"
      tracing:
        enabled: true
    prometheus:
      enabled: true

After (shared MCPTelemetryConfig resource):

# 1. Create a shared MCPTelemetryConfig resource
apiVersion: toolhive.stacklok.dev/v1alpha1
kind: MCPTelemetryConfig
metadata:
  name: shared-otel
spec:
  openTelemetry:
    enabled: true
    endpoint: "otel-collector:4317"
    tracing:
      enabled: true
  prometheus:
    enabled: true
---
# 2. Reference it from your MCPServer/MCPRemoteProxy
spec:
  telemetryConfigRef:
    name: shared-otel
    serviceName: my-server  # per-server override (optional)

VirtualMCPServer

config.telemetry is no longer read by the operator. Use spec.telemetryConfigRef instead (same MCPTelemetryConfig pattern as above).

thv export

thv export --format k8s now prints a stderr warning when telemetry config is detected but cannot be exported inline. Users must create an MCPTelemetryConfig resource manually.

Large PR Justification

  • we're removing entire portions of code

Special notes for reviewers

  • Shared types kept: PrometheusConfig, OpenTelemetryTracingConfig, and OpenTelemetryMetricsConfig are still used by MCPTelemetryConfig and were intentionally retained.
  • Config.Telemetry in shared struct: The Telemetry field in pkg/vmcp/config/config.go is still valid for standalone CLI deployments — only the operator-side fallback was removed.
  • This is PR 1 of 5 in the deprecation removal series before v1beta1 promotion.

Closes #4828

Generated with Claude Code

@github-actions github-actions bot added the size/XL Extra large PR: 1000+ lines changed label Apr 14, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.97%. Comparing base (42f7395) to head (e940bbd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4819      +/-   ##
==========================================
- Coverage   69.10%   68.97%   -0.13%     
==========================================
  Files         530      530              
  Lines       55379    55281      -98     
==========================================
- Hits        38267    38128     -139     
- Misses      14170    14212      +42     
+ Partials     2942     2941       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jerm-dro
jerm-dro previously approved these changes Apr 14, 2026
Copy link
Copy Markdown
Collaborator Author

@ChrisJBurns ChrisJBurns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-Agent Consensus Review

Agents consulted: kubernetes-expert, code-reviewer, toolhive-expert, site-reliability-engineer

Consensus Summary

# Finding Consensus Severity Action
1 Stale comments referencing removed types/functions 10/10 LOW Fix
2 Architecture docs outdated 8/10 MEDIUM Fix
3 thv export silently drops telemetry config 8/10 MEDIUM Discuss
4 Example YAML files have stale deprecation comments 8/10 LOW Fix
5 MCPRemoteProxy pre-existing env var gap 7/10 INFO Note

Overall

Clean, thorough deprecation removal. The structural changes are correct: field and type removals, deepcopy updates, CEL rule removals, controller fallback branch removals, CRD YAML regeneration, and test cleanup are all internally consistent across MCPServer, MCPRemoteProxy, and VirtualMCPServer. No compilation risks, nil pointer issues, or dead code paths found. Shared types (PrometheusConfig, OpenTelemetryTracingConfig, OpenTelemetryMetricsConfig) are correctly retained for MCPTelemetryConfig.

All five findings are non-blocking. The two MEDIUM findings (architecture doc drift and silent telemetry drop in thv export) are polish items that could be addressed in this PR or in a follow-up. The stale comment fixes are straightforward search-and-replace. The MCPRemoteProxy env var gap is pre-existing and out of scope for this PR.

File-level findings (not on diff lines)

[LOW] F1: Stale comments referencing removed types/functions (Consensus: 10/10)

Multiple comments still reference removed types, deleted functions, or stale phrases:

  • mcpserver_controller.go:1024,1634 — "prefer TelemetryConfigRef over deprecated inline"
  • mcpremoteproxy_runconfig.go:112 — "prefer TelemetryConfigRef over deprecated inline Telemetry"
  • mcptelemetryconfig_types.go:36 — references deleted OpenTelemetryConfig type
  • converter_test.go:1484,1618 — references deleted ConvertTelemetryConfig
  • converter.go:126-127 — references CEL mutual exclusion that was removed

Raised by: k8s-reviewer, code-reviewer, toolhive-reviewer, sre-reviewer

[INFO] F5: Pre-existing gap — MCPRemoteProxy missing GenerateOpenTelemetryEnvVarsFromRef (Consensus: 7/10)

Unlike MCPServer and VirtualMCPServer, MCPRemoteProxy never calls GenerateOpenTelemetryEnvVarsFromRef to inject OTEL_RESOURCE_ATTRIBUTES into pods. The removed GenerateOpenTelemetryEnvVars was the only env var injection path. This is pre-existing — not a regression from this PR — but worth noting for a follow-up.

Raised by: sre-reviewer

Documentation

  • docs/arch/09-operator-architecture.md lines 161, 163, 662-664 still reference the now-removed inline telemetry field and CEL mutual-exclusivity rules. Per CLAUDE.md: "When making changes that affect architecture, update relevant docs in docs/arch/."
  • examples/operator/mcp-servers/mcpserver_fetch_otel.yaml:25 and examples/operator/virtual-mcps/vmcp_with_telemetry_ref.yaml:79 describe the field as "deprecated" rather than "removed."

Generated with Claude Code

ChrisJBurns and others added 2 commits April 14, 2026 21:01
The inline `telemetry` field on MCPServerSpec and MCPRemoteProxySpec,
along with the `config.telemetry`/`telemetryConfigRef` mutual-exclusivity
CEL rule on VirtualMCPServer, was deprecated in favor of TelemetryConfigRef
which references a shared MCPTelemetryConfig resource. This removes all
backward-compatibility shim code, CEL rules, deprecated utility functions,
and the TelemetryConfig/OpenTelemetryConfig CRD types ahead of the
v1beta1 API promotion.

Existing CRs using the deprecated inline telemetry field will need to
migrate to TelemetryConfigRef before upgrading.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add stderr warning in thv export when telemetry config is detected
  but cannot be exported inline, matching the existing secrets warning
- Fix stale comment claiming CEL enforces config.telemetry /
  telemetryConfigRef mutual exclusivity (CEL rule was removed)
- Fix normalizeTelemetry doc comment to mention the config.telemetry
  fallback path used by standalone CLI deployments
- Fix stale call-site comment referencing deprecated inline Telemetry

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ChrisJBurns ChrisJBurns force-pushed the remove-deprecated-inline-telemetry branch from 7c4b641 to 2c124e5 Compare April 14, 2026 20:02
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@github-actions github-actions bot dismissed their stale review April 14, 2026 20:06

Large PR justification has been provided. Thank you!

The operator-side converter no longer falls back to Config.Telemetry
for VirtualMCPServer. Operator-managed vMCPs must use TelemetryConfigRef
to configure telemetry. The Config.Telemetry field remains valid for
standalone CLI deployments which read it directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@github-actions github-actions bot removed the size/XL Extra large PR: 1000+ lines changed label Apr 14, 2026
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
@github-actions github-actions bot dismissed their stale review April 14, 2026 20:22

Large PR justification has been provided. Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

Removed deprecated TelemetryConfig, OpenTelemetryConfig, and related
inline telemetry type documentation from the generated CRD API reference.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
The operator no longer reads Config.Telemetry for VirtualMCPServer.
Convert the e2e test to create an MCPTelemetryConfig resource and
reference it via TelemetryConfigRef, matching the required migration
path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
The CEL rule rejecting both config.telemetry and telemetryConfigRef was
removed in this PR. Remove the integration test that validated it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
jerm-dro
jerm-dro previously approved these changes Apr 14, 2026
@ChrisJBurns ChrisJBurns force-pushed the remove-deprecated-inline-telemetry branch from e940bbd to 381b03b Compare April 14, 2026 21:08
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
@ChrisJBurns ChrisJBurns merged commit 14a1e6c into main Apr 14, 2026
75 checks passed
@ChrisJBurns ChrisJBurns deleted the remove-deprecated-inline-telemetry branch April 14, 2026 21:25
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove deprecated inline telemetry field

2 participants