Skip to content

fix(telemetry): warn instead of crashing when OTLP endpoint has no enabled exporters#4648

Merged
peppescg merged 3 commits intomainfrom
issues/4647
Apr 8, 2026
Merged

fix(telemetry): warn instead of crashing when OTLP endpoint has no enabled exporters#4648
peppescg merged 3 commits intomainfrom
issues/4647

Conversation

@peppescg
Copy link
Copy Markdown
Contributor

@peppescg peppescg commented Apr 7, 2026

Summary

  • When an OTLP endpoint is configured (thv config otel set-endpoint) but both tracing and metrics are disabled, thv serve crashes with a fatal validation error (exit code 1)
  • This causes ToolHive Studio to show a "Health check failed" error with no clear indication of the root cause
  • Instead of crashing, we now enable tracing by default when an endpoint is configured but no exporters are enabled, so the endpoint is actually used rather than silently ignored

Test plan

  • Configured an OTLP endpoint (thv config otel set-endpoint localhost:4317) with tracing/metrics not enabled
  • Verified thv serve starts with a warning and tracing enabled by default, instead of crashing
  • Verified existing telemetry tests pass (go test ./pkg/telemetry/...)
  • Verify normal OTLP flow still works when tracing or metrics are explicitly enabled

Fixes #4647

🤖 Generated with Claude Code

…abled exporters

When an OTLP endpoint is configured via `thv config otel set-endpoint`
but both tracing and metrics are disabled, `thv serve` crashes with a
fatal validation error preventing the server from starting.

Instead of failing, log a warning and clear the endpoint so the server
starts normally. This avoids a confusing "Health check failed" error
in ToolHive Studio.

Fixes #4647

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Apr 7, 2026
@peppescg peppescg self-assigned this Apr 7, 2026
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Apr 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.82%. Comparing base (4529b8e) to head (738dc2a).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pkg/telemetry/serve.go 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4648      +/-   ##
==========================================
- Coverage   68.85%   68.82%   -0.03%     
==========================================
  Files         506      506              
  Lines       52449    52460      +11     
==========================================
- Hits        36115    36108       -7     
- Misses      13542    13561      +19     
+ Partials     2792     2791       -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.

…c complexity

Move the unused endpoint check into a dedicated helper function to
keep NewServeProvider under the gocyclo threshold (15).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Apr 7, 2026
…nabled exporters

Instead of clearing the endpoint (which would silently drop telemetry
for users who configured an endpoint expecting it to work), enable
tracing by default so the endpoint is actually used.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Apr 7, 2026
@peppescg peppescg merged commit d04eb02 into main Apr 8, 2026
104 of 111 checks passed
@peppescg peppescg deleted the issues/4647 branch April 8, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

thv serve crashes on startup when OTLP endpoint is configured but tracing/metrics are disabled

3 participants