Repository navigation
Description
Telemetry: retire legacy span attribute dual-emission (useLegacyAttributes)
Summary
pkg/telemetry/middleware.go dual-emits both legacy (pre-OTEL-semconv) and new
span attribute names on every trace span whenever UseLegacyAttributes is
true — the current default. This was introduced in #3729 as a transition
mechanism (see docs/telemetry-migration-guide.md#backward-compatibility) with
an explicit three-stage deprecation timeline:
- Current: default
true, both names emitted. - Future: default flips to
false(legacy names still available, opt-in). - Later: legacy names removed entirely.
No release has been pinned to stages 2 or 3. This issue tracks flipping the
default and, eventually, deleting the legacy code path — so the transition
doesn't linger indefinitely.
Scope
Span (trace) attributes only. Metrics/labels have no equivalent legacy
fallback — they were renamed with a hard cutover (see PR #5956) and are out of
scope here. Logs have no dual-emission mechanism today, so there is nothing to
retire on that signal.
What's gated by the flag today
Every occurrence of if m.config.UseLegacyAttributes in
pkg/telemetry/middleware.go — the full old→new attribute mapping is
documented in docs/telemetry-migration-guide.md#attribute-name-mapping:
- HTTP request attributes (
http.method,http.url,http.scheme,
http.host,http.target,http.user_agent, …) - HTTP response attributes (
http.status_code,http.response_content_length,
http.duration_ms) - MCP protocol attributes (
mcp.method,rpc.system,rpc.service,
mcp.request.id) - Tool/prompt attributes (
mcp.tool.name,mcp.tool.arguments,
mcp.prompt.name) - Transport attribute (
mcp.transport)
Surfaces exposing the flag
- CLI:
--otel-use-legacy-attributes(cmd/thv/app/run_flags.go) - Config file:
use-legacy-attributes(pkg/config/config.go) - Operator CRD:
MCPTelemetryConfig.spec.useLegacyAttributes
(cmd/thv-operator/api/v1beta1/mcptelemetryconfig_types.go)
Proposed steps
- Flip the default to
falseacross all three surfaces above, with a
release-notes callout. Legacy names remain available as an explicit opt-in
for anyone with dashboards/alerts still on the old attribute keys. - After a further deprecation window, delete the legacy code path in
pkg/telemetry/middleware.go(everyif m.config.UseLegacyAttributes
block), theUseLegacyAttributesfield from all three surfaces, and the
corresponding sections ofdocs/telemetry-migration-guide.md. - Update
docs/telemetry-migration-guide.mdto reflect the new state at each
step (this is the doc that currently states the timeline, so it should
track it release-to-release rather than staying static).
Open questions for maintainers
- What release should the default flip land in, and how much notice do
downstream dashboard/alert owners need beforehand? - Should removal (step 2) be tracked as a sub-task of this issue, or split into
its own follow-up once the default-flip has soaked for a release or two?
Related
- Standardize proxy + vMCP metrics to stacklok.*, delete legacy twins #5956 (Standardize proxy + vMCP metrics to
stacklok.*, delete legacy
metric twins — the metrics-side counterpart to this span-attribute cleanup) - Add UseLegacyAttributes flag to telemetry config #3729 (introduced
UseLegacyAttributes)
Activity
jhrozek commentedon Nov 24, 2026
Thanks for writing this up. I checked it against main and it matches: the flag defaults to true in the CLI, config file and operator CRD, and every legacy block in
pkg/telemetry/middleware.gois gated on it. One correction to the scope notes. #5956 did not merge (it was closed), so metrics have not had a cutover either, and the "no equivalent legacy fallback for metrics" note no longer applies. The migration guide still has no release pinned for the default flip. We need to pick that release and write the release note before changing the default. Removal should wait until that change has shipped for at least a release or two. We will probably track it as a follow-up to this issue. Do you plan to send a PR for the default flip, or would you rather we pick it up?