Skip to content

feat: Add support to send OTEL traces via OTLP#4899

Merged
jamescrosswell merged 61 commits into
mainfrom
oltp-integration
May 5, 2026
Merged

feat: Add support to send OTEL traces via OTLP#4899
jamescrosswell merged 61 commits into
mainfrom
oltp-integration

fix: fall through to scope PropagationContext in GetBaggage when no a…

e057d69
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed May 5, 2026 in 3m 14s

4 issues

find-bugs: Found 4 issues (4 low)

Low

Snapshot() ignores _pinnedActivity and re-reads Activity.Current - `src/Sentry.OpenTelemetry.Exporter/OtelPropagationContext.cs:24`

Snapshot() always passes Activity.Current to the new OtelPropagationContext, ignoring the existing _pinnedActivity field. If Snapshot() is called on a context that was already pinned, the resulting snapshot may reference a different (or null) activity than the original, breaking the documented TOCTOU guarantee that 'all values fixed at the current instant' relative to the source.

Also found at:

  • src/Sentry.OpenTelemetry.Exporter/OtelPropagationContext.cs:30-34
GetBaggageHeader enumerates Activity.Baggage without snapshotting - `src/Sentry.OpenTelemetry.Exporter/OtelPropagationContext.cs:156-165`

GetBaggageHeader iterates Current?.Baggage directly. Activity.Baggage is implemented as a linked list and Activity.AddBaggage may mutate it from another thread. Concurrent enumeration during mutation can throw InvalidOperationException or yield inconsistent items, leading to runtime errors when constructing baggage headers for outbound requests.

HttpClient created in HttpClientFactory is never disposed and has no timeout - `src/Sentry.OpenTelemetry.Exporter/SentryTracerProviderBuilderExtensions.cs:63-71`

The HttpClientFactory delegate constructs a new HttpClient via new HttpClient() without configuring a timeout and without any disposal pattern. While OpenTelemetry's OtlpExporter typically caches and reuses the client, the absence of an explicit timeout means a hung Sentry endpoint can stall the exporter indefinitely, and any code path that recreates the client (e.g., reload or reconfigure) will leak the underlying HttpMessageHandler/sockets. Under sustained failure conditions this can contribute to resource exhaustion (DoS).

AddSentryOtlpExporter mutates global OpenTelemetry propagator state - `src/Sentry.OpenTelemetry.Exporter/SentryTracerProviderBuilderExtensions.cs:50-51`

Sdk.SetDefaultTextMapPropagator(defaultTextMapPropagator) is a process-wide side effect executed unconditionally inside an extension method that callers would reasonably expect to only configure the supplied TracerProviderBuilder. If the user has already configured a propagator, or calls AddSentryOtlpExporter on multiple builders, the last call silently overrides previously installed propagators, potentially breaking distributed tracing context propagation in unrelated parts of the application.


Duration: 3m 10s · Tokens: 1.3M in / 8.4k out · Cost: $7.48 (+merge: $0.00)