feat(cloudflare): Add @sentry/cloudflare/vite orchestrion plugin #21967
Draft
JPeer264 wants to merge 4 commits into
Draft
feat(cloudflare): Add @sentry/cloudflare/vite orchestrion plugin #21967JPeer264 wants to merge 4 commits into
JPeer264 wants to merge 4 commits into
Conversation
Contributor
size-limit report 📦
|
…cted Adds the orchestrion diagnostics-channel subscriber integrations (mysql, pg, ...) from @sentry/server-utils to the Cloudflare SDK's default integrations. They are only registered when the orchestrion bundler (or runtime) marker is set, i.e. when the channels were actually injected into the bundle - otherwise nothing ever publishes to them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Exposes a Sentry Vite plugin for Cloudflare Workers that wraps the orchestrion plugin from @sentry/server-utils. It injects diagnostics channels into bundled npm packages (e.g. `mysql`) at build time, so the SDK can trace them without monkey-patching - which wouldn't work in workerd anyway, since there is no require hook to intercept module loading. The subpath is published ESM-only because `@sentry/server-utils/orchestrion/vite` exposes no `require` condition; Vite configs are ESM anyway. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a worker that runs real `mysql` queries against a Dockerized MySQL, built with Vite + `@cloudflare/vite-plugin` and the new `@sentry/cloudflare/vite` plugin. The worker is wrapped manually with `Sentry.withSentry`; the plugin only injects the orchestrion diagnostics channel into the bundled `mysql` package. The tests assert that the queries emit `db` spans with the orchestrion-channel attributes on the request's http.server transaction, including a query nested inside another query's callback (i.e. across mysql's async socket-callback dispatch). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
9c5dcf0 to
d99e2a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a
/viteplugin for Cloudflare that adds Orchestrion on build time. It adds all orchestrion integrations in thedefaultIntegrations, 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({ // The Sentry plugin runs first so its orchestrion transform injects the // `orchestrion:mysql:query` diagnostics channel into the bundled `mysql` // package before `@cloudflare/vite-plugin` finalizes the worker bundle. - plugins: [cloudflare()], + plugins: [sentryCloudflareVitePlugin(), cloudflare()], });Also the migration from pure wrangler to Vite is as easy as just adding
vite.config.tsand prependingvite buildbeforewrangler deploy: https://developers.cloudflare.com/workers/vite-plugin/reference/migrating-from-wrangler-dev/