Repository navigation
feat(attributes): Add page.server_rendering.type attribute - #740
Conversation
The Sentry JavaScript SDK marks a pageload whose HTML the server rendered before the request, such as a Next.js ISR page or a Partial Prerendering shell. That pageload has no server span for its own request, which looks like missing server instrumentation.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
…e the request The first visitor of a page that the server renders on demand gets HTML that was rendered during their own request. That HTML is still reused for later requests, so the attribute is set, but "before the request" and "earlier trace" were wrong for it.
…amic "Partial" alone does not say what is partial, and a key named after static HTML cannot hold a value for pages that the server renders per request. page.server_rendering uses the Next.js terms for server rendering (static and dynamic), and the page namespace avoids keys that look like DOM properties.
d753316 to
8cbdf56
Compare
Lms24
left a comment
There was a problem hiding this comment.
We discussed quite a few options how to name this attribute and settled on the currently proposed name. This creates a new namespace, page which in the future could hold other rather page-related attributes (e.g. information about hydration) than e.g. a browser.*-namespaced attribute.
Given we couldn't come up with a better name fitting an already existing namespace, I think this is fine to merge.
(This was already discussed internally in the JS SDK team, but leaving this context for other reviewers)
Let's wait 2-3 days for other reviews before merging. Thanks!
When Next.js serves a page from its cache (an ISR page, or a `cacheComponents` shell that was prerendered at runtime), the pageload starts its own trace and has no server span. That is correct, but in Sentry it looks like missing server instrumentation. While Next.js prerenders a document, the server now writes a `sentry-cache-origin` meta tag with the `sentry-trace` value of the prerender (instead of nothing). The client never continues it: it sets `page.server_rendering.type` on the pageload (`static` when the whole page came from the cache, `partially_static` when parts of it rendered for this request) and links the prerender with a `cache_origin` link, both at span start, so `tracesSampler` and `ignoreSpans` see them. Like a `use cache` hit, the pageload links only a sampled prerender. So the fixes of #25141 still hold: a cached page does not attach its visitors to a request that was not theirs, and a `sampled=0` value in the tag cannot drop their pageloads. Pages from `next build` get no tag, because the SDK does not run during the build. The attribute and the tag are named without Next.js in them on purpose: other frameworks with prerendering (Nuxt, SvelteKit, Astro, React Router) can set the same attribute. `page.server_rendering.type` is being added to `@sentry/conventions` in getsentry/sentry-conventions#740; `cache_origin` is already a documented `sentry.link.type` value and is what the cache lifecycle view in Sentry reads. Refs JS-3886 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: s1gr1d <32902192+s1gr1d@users.noreply.github.com>
Adds
page.server_rendering.typefor pageload spans. It says how the server rendered the content of the page:static(rendered to reuse it for other requests, like a build-time page, Next.js ISR or Nuxtswr),partially_static(a reused static part plus parts rendered for this request, like Next.js Partial Prerendering), ordynamic(rendered only for this request).A pageload of a
staticpage has no server span for its own request, so in Sentry it looks like missing server instrumentation. The JavaScript SDK sets this attribute at span start, together with acache_originlink to the request that rendered the page (getsentry/sentry-javascript#25318). The browser SDK only copies what the server says through meta tags. It never works the value out itself, so only SDKs that control the server render set it.The attribute describes the render, not the delivery. The browser can't see a CDN hit, so a CDN can reuse a response with any value. Pages that the browser renders (client-side rendering) get no value, because the server rendered no content.