Skip to content

fix: add error handling for insecure HTTP endpoints with TLS client configuration#7914

Merged
dmathieu merged 5 commits intoopen-telemetry:mainfrom
sandy2008:main
Mar 2, 2026
Merged

fix: add error handling for insecure HTTP endpoints with TLS client configuration#7914
dmathieu merged 5 commits intoopen-telemetry:mainfrom
sandy2008:main

Conversation

@sandy2008
Copy link
Copy Markdown
Member

Summary

This PR moves the insecure + TLS config validation into the core OTLP HTTP exporters in opentelemetry-go (trace, metric, and log), instead of relying on validation in external/config-wrapper code.

This aligns with feedback from open-telemetry/opentelemetry-go-contrib PR open-telemetry/opentelemetry-go-contrib#8560: these packages are maintained/released together, so the check should be enforced in this repo as well.

What changed

  • Added exporter-level validation error:
    • "insecure HTTP endpoint cannot use TLS client configuration"
  • Enforced in:
    • otlpmetrichttp client construction
    • otlploghttp client construction
    • otlptracehttp client startup (Start, since NewClient does not return an error)
  • Added tests in all three exporters to cover:
    • Error when WithInsecure() and WithTLSClientConfig(...) are both set
    • No error when a custom WithHTTPClient(...) is provided (preserves existing precedence semantics)

Behavior

  • Invalid config (insecure + TLS config) now fails fast directly in exporters.
  • Existing WithHTTPClient override behavior remains unchanged.

Testing

Ran:

  • go test ./... in exporters/otlp/otlpmetric/otlpmetrichttp
  • go test ./... in exporters/otlp/otlplog/otlploghttp
  • go test ./... in exporters/otlp/otlptrace/otlptracehttp

Related

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.7%. Comparing base (76e6eec) to head (3106348).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7914   +/-   ##
=====================================
  Coverage   81.7%   81.7%           
=====================================
  Files        304     304           
  Lines      23333   23339    +6     
=====================================
+ Hits       19078   19086    +8     
+ Misses      3866    3864    -2     
  Partials     389     389           
Files with missing lines Coverage Δ
exporters/otlp/otlplog/otlploghttp/client.go 83.5% <100.0%> (+0.2%) ⬆️
exporters/otlp/otlpmetric/otlpmetrichttp/client.go 81.0% <100.0%> (+0.2%) ⬆️
exporters/otlp/otlptrace/otlptracehttp/client.go 77.1% <100.0%> (+0.2%) ⬆️

... and 1 file with indirect coverage changes

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

Comment thread exporters/otlp/otlplog/otlploghttp/client.go Outdated
Copy link
Copy Markdown
Member

@dmathieu dmathieu left a comment

Choose a reason for hiding this comment

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

This will need changelog entries.

Comment thread exporters/otlp/otlplog/otlploghttp/client_test.go Outdated
@sandy2008
Copy link
Copy Markdown
Member Author

This will need changelog entries.

@dmathieu Done, added ;)

@sandy2008 sandy2008 requested a review from dmathieu February 17, 2026 11:11
Comment thread CHANGELOG.md Outdated
…onfiguration

Co-authored-by: Damien Mathieu <42@dmathieu.com>
@sandy2008
Copy link
Copy Markdown
Member Author

@pellared @dmathieu Thank you for approving it :) Do you know when can we get it merged :)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants