Repository navigation
feat(nitro): Turn on Nitro's tracing channels from the Vite and Rollup plugins - #26809
sentry-junior[bot] wants to merge 8 commits into
Conversation
…esponse` Without Nitro's `tracingChannel` option, h3 publishes no `h3.request` events, so an app with only `@sentry/node` and its bundler plugin got no parameterized route and no `Server-Timing` headers. Orchestrion now injects a channel into h3's `prepareResponse`, and `nitroIntegration` sets both from it. Adds the `nitro-3-orchestrion` e2e app, which uses only `@sentry/node` and its Vite or Rollup plugin. Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
size-limit report 📦Compared: 73c7b27 (PR test merge using develop at a1fd756) Against: a1fd756 (develop) · base run #67894 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 3 not successful, 80 successful. See the run.
Successful checks
|
`getTraceData()` returns nothing for a client without a DSN, so the Server-Timing tests had no headers to check. Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
Nitro's caching route rules run `prepareResponse` for the response they store, so the trace of the request that rendered it was replayed to every later visitor. Skip Server-Timing for the `cache`, `isr` and `prerender` route rules and for responses a shared cache may store. eve apps now get route names through orchestrion, so its orchestrion variant expects them.
The app tests a Nitro app that uses only `@sentry/node`, so the name now says so.
eve's agent paths are static routes, so the orchestrion variant can expect the span name `POST <path>` instead of a pattern. The `node-nitro-3` endpoint is now `/api/test-static`, since it isn't about transactions.
…p plugins Route names, Server-Timing and the h3 handler and middleware spans now come from Nitro's native tracing channels, which the plugins turn on when the option is unset. This replaces the orchestrion target on h3's `prepareResponse`. Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
prepareResponse| "h3": "latest", | ||
| "nitro": "latest", |
There was a problem hiding this comment.
should these two not also be dependencies (instead of dev dependencies)?
There was a problem hiding this comment.
also let's make these ^3.0.0 or something like this instead
There was a problem hiding this comment.
Yes, they're runtime deps. Moved h3 and nitro to dependencies in 75ec498c.
There was a problem hiding this comment.
h3 is now ^2.0.8. For nitro, ^3.0.0 matches no published version: there's no stable 3.0.0 yet, every Nitro 3 release is a prerelease (3.0.261103-rc is latest), and a caret range without a prerelease tag skips prereleases. So the install would fail. I used ^3.0.261103-rc instead. By semver rules, a prerelease caret only matches prereleases with the same 3.0.261103 version, so in practice this pins 3.0.261103-rc until a stable 3.x ships. The tradeoff: CI no longer picks up new Nitro RCs on its own, which is where the __nitro_instances__ global and the resolver could change. If you'd rather keep tracking new RCs until 3.0.0 is out, latest is the only option for now. Done in 75ec498c.
The app preloads `@sentry/node/import` and calls `Sentry.init()` from a Nitro plugin instead of preloading an `instrument.mjs`. Only Nitro's worker gets a client then, so in dev the tests no longer have to skip a segment span from the dev server. Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
…de-nitro-3 Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
|
Closing: #24900 now plans a dedicated Nitro module ( |
What
A Nitro app with only
@sentry/nodeand its Vite or Rollup plugin now gets the parameterized route,Server-Timingand the h3 handler, middleware, srvx and cache spans, without@sentry/nitro. The plugins turn on Nitro'stracingChanneloption, and thenitroIntegrationsubscribers that@sentry/nitroalready uses do the rest.This also adds the
node-nitro-3e2e app: Vite and the Nitro CLI, dev and prod, plus a variant where the user setstracingChannel: truethemselves. The app uses the setup #24900 now recommends:Sentry.init()in a Nitro plugin and--import @sentry/node/import, so in dev only Nitro's worker has a client.Why
Step 2 of #24900. The native channels need no orchestrion targets in h3's build chunks, and they fire in
nitro deveven though h3 stays external there.nitroproperty, which Nitro's Vite plugin installs as a Nitro module. That coversvite build,vite devandnitro buildwith a Vite config.rollupConfig.plugins, sobuildStarttakes the instance fromglobalThis.__nitro_instances__. That global is not public API; the e2e app's Nitro CLI variants catch a change.src/config/resolvers/tracing.tsin nitrojs/nitro). They change nothing when the option is set, so a user'sfalseand the value@sentry/nitrosets stay.Open decisions:
Server-Timingon the native path has no cache guard yet (skippingcache,israndprerenderroute rules and shared-cacheable responses). That's a separate item in Nitro: instrument through the runtime SDKs and their bundler plugins, deprecate@sentry/nitro#24900.via @mydea.
--
View Session [Sentry]