Skip to content

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

@gkatz2

Description

@gkatz2

Bug description

thv config otel set-tracing-enabled false and thv config otel set-metrics-enabled false report success, but thv run ignores these values. Servers started without explicit --otel-tracing-enabled/--otel-metrics-enabled flags get tracingEnabled: true and metricsEnabled: true in their runconfig regardless of global config.

Two bugs contribute to this:

1. getTelemetryFromFlags skips TracingEnabled/MetricsEnabled fallback (functional)

In cmd/thv/app/run_flags.go, getTelemetryFromFlags applies global config fallbacks for 6 of 8 OTel fields but omits TracingEnabled and MetricsEnabled. Additionally, buildRunConfig passes raw runFlags.OtelTracingEnabled/runFlags.OtelMetricsEnabled to WithTelemetryConfigFromFlags, bypassing the fallback entirely for the proxy runner config.

Since both CLI flags default to true, global config is never consulted and servers always start with telemetry enabled.

2. omitempty on bool fields hides false in config.yaml (cosmetic)

In pkg/config/config.go, OpenTelemetryConfig uses omitempty on MetricsEnabled and TracingEnabled. Since false is Go's zero value, yaml.Marshal drops these fields from the YAML output. PR #3761 fixed this in pkg/telemetry/config.go (the runtime config struct) but not in pkg/config/config.go (the global application config struct).

Steps to reproduce

thv config otel set-tracing-enabled false
thv config otel get-tracing-enabled
# Output: Current OpenTelemetry tracing enabled: false

cat ~/Library/Application\ Support/toolhive/config.yaml | grep tracing
# (no output — omitempty drops the field)

thv run <any-server>
jq '.telemetry_config.tracingEnabled' \
  ~/Library/Application\ Support/toolhive/runconfigs/<server>.json
# Output: true (should be false)

Expected behavior

When tracing-enabled or metrics-enabled is set to false in global config, thv run should respect that value unless overridden by an explicit CLI flag. The false value should also be visible in config.yaml.

Actual behavior

Global config values for tracing-enabled and metrics-enabled are silently ignored. Servers started without explicit CLI flags always start with both enabled (the CLI flag default), regardless of global config.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliChanges that impact CLI functionalitygoPull requests that update go codetelemetry

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions