Skip to content

WIP feat(opentelemetry): Add SentryTraceProvider#21181

Draft
andreiborza wants to merge 9 commits into
developfrom
ab/sentry-tracer-provider
Draft

WIP feat(opentelemetry): Add SentryTraceProvider#21181
andreiborza wants to merge 9 commits into
developfrom
ab/sentry-tracer-provider

Conversation

@andreiborza

Copy link
Copy Markdown
Member

WIP

Comment thread packages/opentelemetry/src/sentryTraceProvider.ts
@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.45 kB - -
@sentry/browser - with treeshaking flags 25.88 kB - -
@sentry/browser (incl. Tracing) 45.93 kB -0.03% -10 B 🔽
@sentry/browser (incl. Tracing + Span Streaming) 47.69 kB -0.02% -8 B 🔽
@sentry/browser (incl. Tracing, Profiling) 50.72 kB -0.02% -9 B 🔽
@sentry/browser (incl. Tracing, Replay) 85.13 kB -0.02% -10 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.72 kB -0.01% -7 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 89.82 kB -0.02% -10 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 102.48 kB -0.01% -6 B 🔽
@sentry/browser (incl. Feedback) 44.62 kB - -
@sentry/browser (incl. sendFeedback) 32.25 kB - -
@sentry/browser (incl. FeedbackAsync) 37.38 kB - -
@sentry/browser (incl. Metrics) 28.52 kB - -
@sentry/browser (incl. Logs) 28.76 kB - -
@sentry/browser (incl. Metrics & Logs) 29.45 kB - -
@sentry/react 29.25 kB - -
@sentry/react (incl. Tracing) 48.23 kB -0.02% -8 B 🔽
@sentry/vue 32.6 kB -0.03% -7 B 🔽
@sentry/vue (incl. Tracing) 47.8 kB -0.02% -8 B 🔽
@sentry/svelte 27.48 kB - -
CDN Bundle 29.84 kB - -
CDN Bundle (incl. Tracing) 47.85 kB -0.02% -6 B 🔽
CDN Bundle (incl. Logs, Metrics) 31.39 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.19 kB -0.02% -6 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 70.7 kB - -
CDN Bundle (incl. Tracing, Replay) 85.2 kB -0.01% -5 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.47 kB -0.01% -8 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 91.05 kB -0.01% -4 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.3 kB -0.01% -7 B 🔽
CDN Bundle - uncompressed 88.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.85 kB +0.02% +16 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.5 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.83 kB +0.02% +16 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 263.72 kB +0.01% +16 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 267.68 kB +0.01% +16 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.42 kB +0.01% +16 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.37 kB +0.01% +16 B 🔺
@sentry/nextjs (client) 50.62 kB -0.01% -5 B 🔽
@sentry/sveltekit (client) 46.33 kB -0.01% -4 B 🔽
@sentry/core/server 75.88 kB +0.04% +25 B 🔺
@sentry/core/browser 63.02 kB +0.03% +13 B 🔺
@sentry/node-core 61.66 kB +0.06% +35 B 🔺
@sentry/node 124.86 kB +0.78% +962 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.05 kB - -
@sentry/node/light 50.55 kB -0.01% -2 B 🔽
@sentry/node - without tracing 75.01 kB +1.19% +877 B 🔺
@sentry/aws-serverless 86.17 kB +1.11% +941 B 🔺
@sentry/cloudflare (withSentry) - minified 172.94 kB +0.03% +49 B 🔺
@sentry/cloudflare (withSentry) 432.62 kB +0.04% +145 B 🔺

View base workflow run

@andreiborza andreiborza force-pushed the ab/sentry-tracer-provider branch from 0f2020a to 71e7c69 Compare May 27, 2026 05:27
Comment thread packages/core/src/tracing/sentrySpan.ts Outdated
*/
public recordException(_exception: unknown, _time?: number | undefined): void {
// noop
public recordException(exception: unknown, time?: SpanTimeInput | undefined): void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can leave this as noop, we do not care about this and do not really support it, doing nothing with events etc.

@andreiborza andreiborza force-pushed the ab/sentry-tracer-provider branch from 71e7c69 to a44215e Compare May 28, 2026 04:15
Comment thread packages/opentelemetry/src/sentryTraceProvider.ts
Comment thread packages/node/src/sdk/initOtel.ts
Comment thread packages/opentelemetry/src/sentryTraceProvider.ts
@andreiborza andreiborza force-pushed the ab/sentry-tracer-provider branch from cf369b6 to 749e7e7 Compare June 6, 2026 22:56
Comment thread packages/node/src/sdk/initOtel.ts
Comment thread packages/core/src/tracing/trace.ts Outdated
@andreiborza andreiborza force-pushed the ab/sentry-tracer-provider branch 6 times, most recently from 8ebaf6b to 2b70730 Compare June 8, 2026 10:54
Comment thread packages/core/src/utils/spanUtils.ts Outdated
@andreiborza andreiborza force-pushed the ab/sentry-tracer-provider branch from 959483b to 87ed1f0 Compare June 8, 2026 14:05
Comment thread packages/opentelemetry/src/sentryTraceProvider.ts
Comment thread packages/core/src/tracing/trace.ts Outdated
Comment thread packages/opentelemetry/src/sentryTraceProvider.ts
Comment thread packages/opentelemetry/src/sentryTraceProvider.ts Outdated
Comment thread packages/core/src/tracing/idleSpan.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5917bab. Configure here.

Comment thread packages/node/src/sdk/initOtel.ts
@andreiborza andreiborza force-pushed the ab/sentry-tracer-provider branch 3 times, most recently from d265e00 to 34725df Compare June 17, 2026 19:06
andreiborza and others added 2 commits June 19, 2026 14:30
`SentrySpan.updateName()` stamps `sentry.source: 'custom'` unconditionally again (as on develop), except for spans branded via `markSpanForOtelSourceInference()`. SentryTraceProvider sets that brand on the spans it creates, so instrumentations renaming them don't pin 'custom' and `applyOtelSpanData` can infer the correct source (e.g. 'route', 'task') at span end — mirroring OTel SDK spans, which carry no Sentry source concept.

This replaces the earlier "only set custom when a source already exists" heuristic, which also unintentionally stopped stamping 'custom' on user-created child spans that start without a source. Branding scopes the carve-out to exactly the provider-created spans. Standalone this commit is develop-equivalent (nothing sets the brand yet); the follow-up SentryTraceProvider PR flips it on.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a minimal OpenTelemetry `TracerProvider` that creates native Sentry spans
instead of bridging through the full OTel SDK. Includes the `SentryTracer`,
`applyOtelSpanData` OTel-to-Sentry inference, sampling-decision propagation via
the span context, and supporting changes to the async context strategy,
setup checks, and DSC/root-span-name enhancement. Exposed for wiring via
`_INTERNAL_startInactiveSpan` in core. Gated behind the consumer SDK and has no
effect until enabled there.

Co-Authored-By: Claude <noreply@anthropic.com>
andreiborza and others added 2 commits June 19, 2026 14:35
Add the `useSentryTraceProvider` experimental option and the Node setup path
that registers the `SentryTraceProvider` (and its async context strategy)
instead of the full OpenTelemetry SDK tracer provider when enabled. Skips the
`SentrySpanProcessor`/`SentrySampler` setup that the provider replaces, guards
the HTTP server-spans integration for the missing async-local-storage lookup,
and finalizes span data on `spanEnd`. Defaults to off.

Co-Authored-By: Claude <noreply@anthropic.com>
@andreiborza andreiborza force-pushed the ab/sentry-tracer-provider branch from 916e70a to a6caf6a Compare June 19, 2026 12:48
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.

2 participants