feat(cloudflare): Read wrangler config and resolve the Sentry options module#22291
Draft
JPeer264 wants to merge 4 commits into
Draft
feat(cloudflare): Read wrangler config and resolve the Sentry options module#22291JPeer264 wants to merge 4 commits into
JPeer264 wants to merge 4 commits into
Conversation
JPeer264
force-pushed
the
jp/orchestrion-cloudflare-wrangler-read
branch
from
July 15, 2026 11:58
8343656 to
eb2d012
Compare
Contributor
size-limit report 📦
|
timfish
requested changes
Jul 15, 2026
Collaborator
There was a problem hiding this comment.
unfortunately there is no library from Cloudflare (yet) that is reading the wrangler config.
Wrangler has a unstable_readConfig API briefly mentioned here although not fully documented. This is what their Vite plugin uses and it's used a lot elsewhere so should be stable enough. It resolves and normalise the wrangler config for you.
… global marker Let SDKs enable orchestrion diagnostics-channel integrations without statically importing (and therefore shipping) their subscriber code. A bundler plugin puts the integration factories on `globalThis.__SENTRY_ORCHESTRION__`, and `getRegisteredChannelIntegrations()` reads them at `init()`, activating only the integrations whose module was actually transformed into the bundle. - Vite plugin (`@sentry/server-utils/orchestrion/vite`) instruments both `vite build` and `vite dev`. In dev, dependencies are pre-bundled by the optimizer before the `transform` hook runs, so the code transform is wired into the optimizer instead (esbuild on classic Vite, Rolldown on Vite 8), and the registration import is injected structurally into the entry since `renderChunk`/`getModuleInfo().isEntry` are unavailable there. - Warn when a module's transform fails (at build time, and once per isolate in debug runtime): the package ships without its diagnostics channels, so its integration is skipped and its spans would otherwise silently go missing. - Guard the CJS-only `pathToFileURL` import so the ESM build carries no unused external import. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> feat: Remove failedModules usage fix: Call the banner via virtual module test: for..of -> it.each (insert drake meme) chore: Fix a wrong rebase chore: Fix lint
JPeer264
force-pushed
the
jp/orchestrion-cloudflare
branch
from
July 16, 2026 06:41
afcb71d to
8517822
Compare
JPeer264
force-pushed
the
jp/orchestrion-cloudflare-wrangler-read
branch
from
July 16, 2026 06:41
eb2d012 to
a7e002e
Compare
…via the global marker
…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>
… module
Add the building blocks the auto-instrument Vite plugin will use, with no wiring
into a plugin yet:
- `wranglerConfig`: locate and parse `wrangler.{json,jsonc,toml}`, returning the
worker entry (`main`) and the configured Durable Object class names.
- `instrumentFile`: find a conventional `instrument.server.{ts,js,mjs,cjs}` next
to the entry and build the options import, falling back to an env-based
callback when absent.
- `defineCloudflareOptions`: identity helper that gives the options callback its
type in that module.
Adds `jsonc-parser`, `smol-toml`, and `magic-string` as dependencies.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
JPeer264
force-pushed
the
jp/orchestrion-cloudflare
branch
from
July 16, 2026 07:34
8517822 to
7e8f420
Compare
JPeer264
force-pushed
the
jp/orchestrion-cloudflare-wrangler-read
branch
from
July 16, 2026 07:34
a7e002e to
b5454ef
Compare
JPeer264
force-pushed
the
jp/orchestrion-cloudflare
branch
2 times, most recently
from
July 17, 2026 07:21
d2a6c9f to
dbd5795
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.
Add the building blocks the auto-instrument Vite plugin will use, with no wiring into a plugin yet. These will come in a follow-up PR one by one.
wranglerConfig: locate and parsewrangler.{json,jsonc,toml}, returning the worker entry (main) and the configured Durable Object class names.instrumentFile: find a conventionalinstrument.server.{ts,js,mjs,cjs}next to the entry and build the options import, falling back to an env-based callback when absent.defineCloudflareOptions: identity helper that gives the options callback its type in that module.jsonc-parserandsmol-tomlare also used bywrangleritself, unfortunately there is no library from Cloudflare (yet) that is reading the wrangler config.The
instrument.server.*config can and should be written like the following:defineCloudflareOptionsis only adding typings forenvso it is easier it can also be used like the following:or
Future possibilities
For now there is a shared config for all instrumentations. In the future there would be the possibility to have different exports and map them to the actual bindings. E.g.: