Skip to content

feat(cloudflare): Add @sentry/cloudflare/vite orchestrion plugin #21967

Merged
JPeer264 merged 4 commits into
jp/orchestrion-integrationsfrom
jp/orchestrion-cloudflare
Jul 21, 2026
Merged

feat(cloudflare): Add @sentry/cloudflare/vite orchestrion plugin #21967
JPeer264 merged 4 commits into
jp/orchestrion-integrationsfrom
jp/orchestrion-cloudflare

Conversation

@JPeer264

@JPeer264 JPeer264 commented Jul 6, 2026

Copy link
Copy Markdown
Member

closes #22062

This adds a /vite plugin for Cloudflare that adds Orchestrion on build time. It adds all orchestrion integrations in the defaultIntegrations, which adds more bundle size - this is not optimal and will be adapted in a follow up PR. Best case scenario: Only add integrations which the user really installed.

For now the user only has to add the following to the Vite config:

import { cloudflare } from '@cloudflare/vite-plugin';
+ import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
import { defineConfig } from 'vite';

export default defineConfig({
- plugins: [cloudflare()],
+ plugins: [
+   cloudflare(),
+   sentryCloudflareVitePlugin({
+     _experimental: {
+       useDiagnosticsChannelInjection: true,
+     }
+   })
+ ],
});

The _experimental.useDiagnosticsChannelInjection is the same as we have in Next.js via the Webpack plugin - so it stays consistent

Also the migration from pure wrangler to Vite is as easy as just adding vite.config.ts and prepending vite build before wrangler deploy: https://developers.cloudflare.com/workers/vite-plugin/reference/migrating-from-wrangler-dev/

@JPeer264 JPeer264 self-assigned this Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.75 kB - -
@sentry/browser - with treeshaking flags 26.18 kB - -
@sentry/browser (incl. Tracing) 46.56 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.37 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.36 kB - -
@sentry/browser (incl. Tracing, Replay) 85.84 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.46 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.55 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.21 kB - -
@sentry/browser (incl. Feedback) 44.93 kB - -
@sentry/browser (incl. sendFeedback) 32.55 kB - -
@sentry/browser (incl. FeedbackAsync) 37.69 kB - -
@sentry/browser (incl. Metrics) 28.83 kB - -
@sentry/browser (incl. Logs) 29.05 kB - -
@sentry/browser (incl. Metrics & Logs) 29.76 kB - -
@sentry/react 29.54 kB - -
@sentry/react (incl. Tracing) 48.84 kB - -
@sentry/vue 33.17 kB - -
@sentry/vue (incl. Tracing) 48.52 kB - -
@sentry/svelte 27.78 kB - -
CDN Bundle 30.14 kB - -
CDN Bundle (incl. Tracing) 48.53 kB - -
CDN Bundle (incl. Logs, Metrics) 31.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.83 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.99 kB - -
CDN Bundle (incl. Tracing, Replay) 86.05 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.35 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.12 kB - -
CDN Bundle - uncompressed 89.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.73 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.59 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.71 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.35 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.96 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.93 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.67 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.62 kB - -
@sentry/nextjs (client) 51.36 kB - -
@sentry/sveltekit (client) 46.99 kB - -
@sentry/core/server 80.26 kB - -
@sentry/core/browser 66.69 kB - -
@sentry/node-core 63.21 kB - -
@sentry/node 125.73 kB -0.01% -1 B 🔽
@sentry/node (incl. diagnostics channel injection) 149.77 kB +0.17% +252 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB -0.01% -2 B 🔽
@sentry/node/light 51.32 kB - -
@sentry/node - without tracing 74.92 kB - -
@sentry/aws-serverless 84.15 kB - -
@sentry/cloudflare (withSentry) - minified 197.66 kB +0.08% +148 B 🔺
@sentry/cloudflare (withSentry) 486.61 kB +0.16% +741 B 🔺

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch 8 times, most recently from 18b7454 to 596608d Compare July 13, 2026 09:48
@JPeer264
JPeer264 changed the base branch from develop to jp/orchestrion-integrations July 13, 2026 12:53
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from 596608d to f5c454b Compare July 13, 2026 13:08
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from 4d78130 to b66e928 Compare July 14, 2026 13:26
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from 515173e to 45a679c Compare July 14, 2026 13:32
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from b66e928 to 332ece3 Compare July 14, 2026 14:44
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from 45a679c to 6e6c5b7 Compare July 14, 2026 14:44
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch 4 times, most recently from baafdd8 to 931a37a Compare July 15, 2026 07:30
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from 6e6c5b7 to d6c0992 Compare July 15, 2026 08:56
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from 95c6874 to c0dfebc Compare July 15, 2026 09:20
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch 4 times, most recently from 4da617b to 965040a Compare July 15, 2026 09:43
@JPeer264

Copy link
Copy Markdown
Member Author

bugbot run

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 965040a. Configure here.

@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch 2 times, most recently from c7a4227 to f750c0d Compare July 15, 2026 10:50
@JPeer264
JPeer264 requested a review from a team as a code owner July 15, 2026 10:59
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch 2 times, most recently from 2a66913 to 7249eff Compare July 15, 2026 11:16
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from e7262f3 to 6713fc3 Compare July 15, 2026 11:38
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from 7249eff to afcb71d Compare July 15, 2026 11:38
Comment thread packages/cloudflare/package.json Outdated
Comment on lines +51 to +52
"types": "./build/types/vite/index.d.ts",
"import": "./build/esm/vite/index.js"

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.

Don't you need the cjs export here as well? Other exports have it 👀

Edit: I just noticed the comment above that it's only ESM. But this PR could fix that: #22286

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thx. I'll add it

@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from 6713fc3 to 0d56181 Compare July 16, 2026 06:39
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch 2 times, most recently from 8517822 to 7e8f420 Compare July 16, 2026 07:34
Comment thread packages/cloudflare/src/sdk.ts Outdated
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from b59ebba to 157e383 Compare July 17, 2026 06:57
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from cfc41ca to d2a6c9f Compare July 17, 2026 06:57
Comment thread packages/cloudflare/test/sdk.test.ts Outdated
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from 157e383 to 6755627 Compare July 17, 2026 07:21
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from d2a6c9f to dbd5795 Compare July 17, 2026 07:21
@JPeer264
JPeer264 force-pushed the jp/orchestrion-integrations branch from 713422f to 022aa6a Compare July 21, 2026 08:32
JPeer264 and others added 2 commits July 21, 2026 10:32
…tics channels

Integrate the server-utils orchestrion channel-integration mechanism into the
Cloudflare SDK, so bundled npm packages (e.g. `mysql`) are traced without
monkey-patching, which workerd doesn't support anyway.

- Add the `@sentry/cloudflare/vite` plugin, which runs the orchestrion transform
  (injecting `diagnostics_channel.tracingChannel` calls) and injects a
  registration module that puts the channel-subscriber integrations on the
  global marker. Workers built without the plugin don't ship that code.
- `getDefaultIntegrations()` reads the registered integrations from the marker
  at `init()`, activating only those whose module was actually transformed, and
  warns (debug only, once per isolate) about modules whose transform failed.
- Add a Cloudflare + MySQL e2e test app exercising real `db` spans in workerd.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tics channels

Integrate the server-utils orchestrion channel-integration mechanism into the
Cloudflare SDK, so bundled npm packages (e.g. `mysql`) are traced without
monkey-patching, which workerd doesn't support anyway.

- Add the `@sentry/cloudflare/vite` plugin, which runs the orchestrion transform
  (injecting `diagnostics_channel.tracingChannel` calls) and injects a
  registration module that puts the channel-subscriber integrations on the
  global marker. Workers built without the plugin don't ship that code.
- `getDefaultIntegrations()` reads the registered integrations from the marker
  at `init()`, activating only those whose module was actually transformed, and
  warns (debug only, once per isolate) about modules whose transform failed.
- Add a Cloudflare + MySQL e2e test app exercising real `db` spans in workerd.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/orchestrion-cloudflare branch from dbd5795 to 494d73c Compare July 21, 2026 08:33
@JPeer264
JPeer264 merged commit b5f57a6 into develop Jul 21, 2026
312 of 313 checks passed
@JPeer264
JPeer264 deleted the jp/orchestrion-cloudflare branch July 21, 2026 09:12
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.

Add more instrumentation with Orchestrion

4 participants