Skip to content

fix(sveltekit): Register the OpenTelemetry tracer provider on Cloudflare - #23632

Merged
JPeer264 merged 1 commit into
developfrom
jp/cloudflare-sveltekit-otel-spans
Aug 26, 2026
Merged

fix(sveltekit): Register the OpenTelemetry tracer provider on Cloudflare#23632
JPeer264 merged 1 commit into
developfrom
jp/cloudflare-sveltekit-otel-spans

Conversation

@JPeer264

Copy link
Copy Markdown
Member

initCloudflareSentryHandle sets enableOpenTelemetrySetup: true, but wrapped the request with wrapRequestHandler from @sentry/cloudflare/request, which initializes the SDK via initBaseSdk and ignores that option. Kit tracing spans emitted via @opentelemetry/api were therefore dropped.

Add an internal, init-backed _INTERNAL_wrapRequestHandler to the main @sentry/cloudflare entry point and use it from SvelteKit. The /request entry point stays OTel-free on purpose, as it has to work without nodejs_compat. Integration tests pin both behaviours in workerd.

`initCloudflareSentryHandle` sets `enableOpenTelemetrySetup: true`, but wrapped the request with
`wrapRequestHandler` from `@sentry/cloudflare/request`, which initializes the SDK via `initBaseSdk`
and ignores that option. Kit tracing spans emitted via `@opentelemetry/api` were therefore dropped.

Add an internal, `init`-backed `_INTERNAL_wrapRequestHandler` to the main `@sentry/cloudflare`
entry point and use it from SvelteKit. The `/request` entry point stays OTel-free on purpose, as it
has to work without `nodejs_compat`. Integration tests pin both behaviours in workerd.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JPeer264 JPeer264 self-assigned this Aug 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.6 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.51 kB - -
@sentry/browser (incl. Tracing, Replay) 88.04 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.44 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.75 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.44 kB - -
@sentry/browser (incl. Feedback) 45.81 kB - -
@sentry/browser (incl. sendFeedback) 33.36 kB - -
@sentry/browser (incl. FeedbackAsync) 38.46 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.31 kB - -
@sentry/react (incl. Tracing) 50.79 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.82 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.07 kB - -
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.95 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.98 kB - -
CDN Bundle (incl. Tracing, Replay) 86.56 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.25 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.69 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.38 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.36 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.12 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.79 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.48 kB - -
@sentry/nextjs (client) 53.33 kB - -
@sentry/sveltekit (client) 49.03 kB - -
@sentry/core/server 65.08 kB - -
@sentry/core/browser 52.38 kB - -
@sentry/node 121.44 kB -0.04% -39 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.19 kB - -
@sentry/node - without tracing 87.62 kB +0.03% +19 B 🔺
@sentry/aws-serverless 95.77 kB +0.03% +26 B 🔺
@sentry/cloudflare (withSentry) - minified 199.5 kB - -
@sentry/cloudflare (withSentry) 495.46 kB - -

View base workflow run

@JPeer264
JPeer264 marked this pull request as ready for review August 26, 2026 10:21
@JPeer264
JPeer264 requested review from a team as code owners August 26, 2026 10:21
@JPeer264
JPeer264 requested review from andreiborza, chargome, isaacs and nicohrubec and removed request for a team August 26, 2026 10:21

@andreiborza andreiborza left a comment

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.

Nice!

@JPeer264
JPeer264 merged commit 6151ab5 into develop Aug 26, 2026
83 checks passed
@JPeer264
JPeer264 deleted the jp/cloudflare-sveltekit-otel-spans branch August 26, 2026 11:21
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