Skip to content

Respect global config for OTel tracing and metrics enabled#4326

Open
gkatz2 wants to merge 1 commit intostacklok:mainfrom
gkatz2:fix/otel-global-tracing-metrics-config
Open

Respect global config for OTel tracing and metrics enabled#4326
gkatz2 wants to merge 1 commit intostacklok:mainfrom
gkatz2:fix/otel-global-tracing-metrics-config

Conversation

@gkatz2
Copy link
Contributor

@gkatz2 gkatz2 commented Mar 24, 2026

Summary

  • thv config otel set-tracing-enabled false was silently ignored by thv run because getTelemetryFromFlags had no fallback for TracingEnabled or MetricsEnabled, and buildRunConfig bypassed the fallback entirely for the proxy runner config
  • Users could not globally disable telemetry without passing CLI flags on every invocation

Fixes #4323

Type of change

  • Bug fix

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Deployed a local build and verified:

  1. With global config tracing-enabled: false and metrics-enabled: false, thv run produces a runconfig with null telemetry (no telemetry initialized)
  2. With explicit --otel-tracing-enabled=true, CLI flag correctly overrides global config
  3. config.yaml now shows tracing-enabled: false instead of silently dropping the field

Changes

File Change
pkg/config/config.go Change TracingEnabled/MetricsEnabled from bool with omitempty to *bool without omitempty, matching the existing UseLegacyAttributes pattern
cmd/thv/app/run_flags.go Add config fallback for both fields in getTelemetryFromFlags; use resolved values in buildRunConfig; return nil from createTelemetryConfig when both signals are disabled
cmd/thv/app/otel.go Update setters/getters/unsetters for *bool
cmd/thv/app/run_flags_test.go Update existing tests and add 4 new cases for tracing/metrics fallback

Does this introduce a user-facing change?

thv config otel set-tracing-enabled and set-metrics-enabled now take effect when starting servers with thv run. Previously these settings were silently ignored.

Special notes for reviewers

The *bool pattern (nil = never set, false = explicitly disabled) is necessary because the CLI defaults for these flags are true, unlike Insecure and EnablePrometheusMetricsPath which default to false. A struct-level comment on OpenTelemetryConfig explains this distinction.

Generated with Claude Code

thv config otel set-tracing-enabled false was silently ignored by
thv run because getTelemetryFromFlags had no fallback for these
two fields, and buildRunConfig bypassed the fallback entirely for
the proxy runner config. Users could not globally disable telemetry
without passing CLI flags on every invocation.

Fixes stacklok#4323

Signed-off-by: Greg Katz <gkatz@indeed.com>
@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global OTel tracing-enabled and metrics-enabled config ignored by thv run

1 participant