Skip to content

fix: baggage extract preserves context; OTLP endpoint scheme determines TLS#89

Merged
michaelbushe merged 1 commit into
mainfrom
fix/baggage-extract-scheme-insecure
Jul 20, 2026
Merged

fix: baggage extract preserves context; OTLP endpoint scheme determines TLS#89
michaelbushe merged 1 commit into
mainfrom
fix/baggage-extract-scheme-insecure

Conversation

@michaelbushe

Copy link
Copy Markdown
Member

Fixes #87, fixes #88 — the two SDK bugs surfaced by the reference-demo review.

#87 — baggage extract clobber

W3CBaggagePropagator.extract returned OTel.context() when the baggage header was absent, so the spec-default composite (tracecontext → baggage) threw away the span context it had just extracted for any request without baggage — most requests from most clients. Now returns the passed context unchanged (Propagators API spec). The reference demo's hand-ordered extraction workaround can be retired after this ships.

#88 — scheme-determined TLS

Per the OTLP exporter spec, the endpoint scheme indicates connection security, and OTEL_EXPORTER_OTLP_INSECURE "only applies … without the http or https scheme." New shared OTelEnv.resolveOtlpSecure implements the precedence (explicit secure > scheme > env insecure > secure default) across traces, metrics, and logs. Bare host:port endpoints are guarded against Uri's bogus-scheme parsing. Bonus parity fix: metrics now honor OTEL_EXPORTER_OTLP_METRICS_INSECURE, which was parsed and dropped.

Behavior change (documented in CHANGELOG): http:// endpoints now connect insecure without needing the extra flag — the footgun every consumer worked around. https:// and scheme-less endpoints behave as before.

Tests

  • Baggage: extract-without-header returns the same context; composite tracecontext→baggage regression preserving the trace id.
  • resolveOtlpSecure: full precedence matrix incl. env-vs-scheme conflicts and the collector:4317 bogus-scheme guard; in-process pipeline check that an http:// env endpoint initializes without the insecure flag.
  • Full suite green via ./tool/test.sh.

🤖 Generated with Claude Code

Fixes #87: W3CBaggagePropagator.extract returned a fresh context when
the baggage header was absent, discarding the span context the
tracecontext stage of the spec-default composite had just extracted —
breaking traces at every service boundary for baggage-less requests.
Extract now returns the passed context unchanged, per the Propagators
API spec.

Fixes #88: OTLP endpoint schemes now determine connection security per
the OTLP spec: http:// is insecure, https:// secure, and
OTEL_EXPORTER_OTLP_INSECURE (+ per-signal variants) applies only to
scheme-less endpoints; explicit programmatic secure still wins.
Shared across all three signals via OTelEnv.resolveOtlpSecure; metrics
now honor OTEL_EXPORTER_OTLP_METRICS_INSECURE (was parsed, ignored).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michaelbushe
michaelbushe merged commit 9dd203f into main Jul 20, 2026
6 checks passed
@michaelbushe
michaelbushe deleted the fix/baggage-extract-scheme-insecure branch July 20, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant