Skip to content

feat(attributes): Add page.server_rendering.type attribute - #740

Merged
s1gr1d merged 8 commits into
mainfrom
sig/document-static-html
Oct 30, 2026
Merged

s1gr1d merged 8 commits into
mainfrom
sig/document-static-html

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Adds page.server_rendering.type for 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 Nuxt swr), partially_static (a reused static part plus parts rendered for this request, like Next.js Partial Prerendering), or dynamic (rendered only for this request).

A pageload of a static page 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 a cache_origin link 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.

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

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-conventions Ready Ready Preview Oct 30, 2026 11:58am UTC

Request Review

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (attributes) Add page.server_rendering.type attribute by s1gr1d in #740

Internal Changes 🔧

  • Deprecate gen_ai.handoff op by alexander-alderman-webb in #754

🤖 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.
@s1gr1d s1gr1d changed the title feat(attributes): Add document.static_html attribute feat(attributes): Add page.server_rendering attribute Oct 21, 2026
…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.
@s1gr1d s1gr1d changed the title feat(attributes): Add page.server_rendering attribute feat(attributes): Add page.server_rendering.type attribute Oct 27, 2026
@s1gr1d
s1gr1d marked this pull request as ready for review October 27, 2026 12:58

@Lms24 Lms24 left a comment

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.

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!

@s1gr1d
s1gr1d enabled auto-merge (squash) October 30, 2026 11:57
@s1gr1d
s1gr1d merged commit 62c4a27 into main Oct 30, 2026
17 checks passed
@s1gr1d
s1gr1d deleted the sig/document-static-html branch October 30, 2026 12:03
chargome added a commit to getsentry/sentry-javascript that referenced this pull request Oct 30, 2026
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>

This branch was successfully deployed

1 active deployment
Preview — 8b25c304 Deployed Oct 30, 2026 by vercel[bot]
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.

3 participants