Skip to content

feat(otlp): support INSECURE environment variables for gRPC#3365

Open
bryantbiggs wants to merge 2 commits intoopen-telemetry:mainfrom
bryantbiggs:feat/otlp-insecure-env-var
Open

feat(otlp): support INSECURE environment variables for gRPC#3365
bryantbiggs wants to merge 2 commits intoopen-telemetry:mainfrom
bryantbiggs:feat/otlp-insecure-env-var

Conversation

@bryantbiggs
Copy link
Copy Markdown
Contributor

@bryantbiggs bryantbiggs commented Feb 20, 2026

Summary

Add support for 4 INSECURE environment variables per the OTLP exporter specification (SHOULD-level):

  • OTEL_EXPORTER_OTLP_INSECURE (generic)
  • OTEL_EXPORTER_OTLP_TRACES_INSECURE
  • OTEL_EXPORTER_OTLP_METRICS_INSECURE
  • OTEL_EXPORTER_OTLP_LOGS_INSECURE

Per the spec, INSECURE only applies to gRPC (not HTTP — HTTP security is determined by URL scheme). There is intentionally no programmatic builder method — this is env-var-only per spec.

Behavior

When an endpoint has no explicit scheme (e.g., collector.example.com:4317):

  • INSECURE=true → prepends http:// (plaintext)
  • INSECURE=false (default) → prepends https:// and auto-applies ClientTlsConfig::new() when TLS features are enabled

Endpoints with an explicit http:// or https:// scheme are unaffected (scheme detection is case-insensitive).

Signal-specific env var takes precedence over generic; "true" (case-insensitive) = insecure, anything else = secure.

Breaking behavior change

Schemeless endpoints (e.g., collector.example.com:4317) now default to https:// instead of being passed as-is to Channel::from_shared. Users with schemeless endpoints connecting to plaintext gRPC servers should set OTEL_EXPORTER_OTLP_INSECURE=true. Endpoints with an explicit http:// scheme (including the default http://localhost:4317) are unaffected.

Test plan

  • cargo clippy -p opentelemetry-otlp --all-targets --all-features -- -D warnings passes
  • cargo test -p opentelemetry-otlp --all-features — 117 unit + 2 integration + 21 doc-tests pass
  • 5 unit tests for resolve_insecure(): signal overrides generic, default is false, case-insensitive, non-true values return false, falls back to generic
  • 4 integration tests for build_channel with INSECURE: schemeless+secure errors without TLS, schemeless+insecure succeeds, schemeless defaults to https, explicit http:// ignores INSECURE env
  • All tests use temp_env::with_var_unset for signal-specific var to prevent parallel test interference

Resolves: #774
Resolves: #984

@bryantbiggs bryantbiggs requested a review from a team as a code owner February 20, 2026 15:52
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 98.05825% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.3%. Comparing base (9650783) to head (e976192).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-otlp/src/exporter/tonic/mod.rs 94.5% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3365   +/-   ##
=====================================
  Coverage   83.2%   83.3%           
=====================================
  Files        128     128           
  Lines      25045   25144   +99     
=====================================
+ Hits       20858   20956   +98     
- Misses      4187    4188    +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.

@bryantbiggs bryantbiggs force-pushed the feat/otlp-insecure-env-var branch 4 times, most recently from c473874 to d638639 Compare March 6, 2026 01:46
Add support for 4 INSECURE environment variables per the OTLP exporter
specification (SHOULD-level):

- OTEL_EXPORTER_OTLP_INSECURE (generic)
- OTEL_EXPORTER_OTLP_TRACES_INSECURE
- OTEL_EXPORTER_OTLP_METRICS_INSECURE
- OTEL_EXPORTER_OTLP_LOGS_INSECURE

Per the spec, INSECURE only applies to gRPC (not HTTP - HTTP security
is determined by URL scheme). There is intentionally no programmatic
builder method - this is env-var-only per spec. When an endpoint has
no explicit scheme:
- INSECURE=true: connect without TLS (prepend http://)
- INSECURE=false (default): connect with TLS (prepend https://, auto-
  apply ClientTlsConfig::new() when TLS features are enabled)

Endpoints with explicit http:// or https:// scheme ignore the INSECURE
flag entirely. Scheme detection is case-insensitive.

Note: Schemeless endpoints (e.g., collector.example.com:4317) now
default to https:// instead of being passed as-is. Set
OTEL_EXPORTER_OTLP_INSECURE=true for plaintext connections.

Refs: open-telemetry#774, open-telemetry#984
@bryantbiggs bryantbiggs force-pushed the feat/otlp-insecure-env-var branch from a4a54f1 to e976192 Compare March 21, 2026 01:25
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.

Support more env vars for exporter configuration Support all configuration of otlp exporter

1 participant