Skip to content

fix(core): Use the final segment span name for streamed spans that end before a rename - #26178

Draft
chargome wants to merge 1 commit into
developfrom
fix-stale-segment-name
Draft

chargome wants to merge 1 commit into
developfrom
fix-stale-segment-name

Conversation

@chargome

@chargome chargome commented Nov 6, 2026

Copy link
Copy Markdown
Member

Why: With span streaming, each span copies the segment span's name into sentry.segment.name when it ends. If the segment span is renamed later (Next.js does this on every request once the route is known), spans that ended earlier keep the old name and don't show up when searching by the final name. The span buffer now refreshes the value when the trace is sent, unless the user or beforeSendSpan changed it.

Unsure about: Renames that Next.js applies only to the serialized segment span in processSegmentSpan (late route fill-in, /_error, query stripping) are not picked up yet. I'd handle those in a follow-up.

Closes #26080

…d before a rename

Spans are captured when they end, so a child that ended before the
segment span was renamed kept the old sentry.segment.name. The span
buffer now refreshes it from the segment span when the trace is sent,
unless the value was changed by the user or beforeSendSpan.

Fixes #26080

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chargome chargome self-assigned this Nov 6, 2026
@chargome

chargome commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e1eae84. Configure here.

.expect({
span: container => {
const segmentNames = Object.fromEntries(
container.items.map(span => [span.name, span.attributes?.['sentry.segment.name']?.value]),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test uses hard-coded attribute name

Low Severity

The new integration test asserts on 'sentry.segment.name' as a string literal. Testing conventions require span attribute assertions to use the @sentry/conventions constant (SENTRY_SEGMENT_NAME), matching the unit tests in this PR. Flagged because that conventions-constants rule is listed as applying to test files.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit e1eae84. Configure here.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 799e0f1 (PR test merge using develop at a1a1de0)

Against: a1a1de0 (develop) · base run #65235

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 29.92 kB - -
@sentry/browser - with treeshaking flags 28.08 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.97 kB - -
@sentry/browser (incl. Tracing) 52.29 kB +0.18% +91 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 52.3 kB +0.17% +88 B 🔺
@sentry/browser (incl. Tracing, Profiling) 55.27 kB +0.17% +89 B 🔺
@sentry/browser (incl. Tracing, Replay) 92.61 kB +0.11% +93 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.29 kB +0.12% +92 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 97.34 kB +0.1% +95 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 110.34 kB +0.09% +98 B 🔺
@sentry/browser (incl. Feedback) 47.52 kB - -
@sentry/browser (incl. sendFeedback) 35.02 kB - -
@sentry/browser (incl. FeedbackAsync) 40.13 kB - -
@sentry/browser (incl. Metrics) 31.48 kB - -
@sentry/browser (incl. Logs) 31.77 kB - -
@sentry/browser (incl. Metrics & Logs) 32.45 kB - -
@sentry/react 31.78 kB - -
@sentry/react (incl. Tracing) 54.76 kB +0.27% +143 B 🔺
@sentry/vue 38.33 kB +0.26% +96 B 🔺
@sentry/vue (incl. Tracing) 55.33 kB +0.17% +92 B 🔺
@sentry/svelte 29.95 kB - -
@sentry/remix (Remix 3 client bundle) 57.92 kB +0.17% +96 B 🔺
CDN Bundle 31.72 kB - -
CDN Bundle (incl. Tracing) 52.89 kB +0.16% +81 B 🔺
CDN Bundle (incl. Logs, Metrics) 34.52 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.39 kB +0.14% +76 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 75.9 kB - -
CDN Bundle (incl. Tracing, Replay) 91.06 kB +0.09% +79 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.62 kB +0.09% +83 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 97.19 kB +0.09% +81 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.8 kB +0.09% +88 B 🔺
CDN Bundle - uncompressed 92.76 kB - -
CDN Bundle (incl. Tracing) - uncompressed 156.02 kB +0.16% +245 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.29 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.79 kB +0.15% +245 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.85 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.71 kB +0.09% +245 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.47 kB +0.09% +245 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 291.41 kB +0.09% +245 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.17 kB +0.09% +245 B 🔺
@sentry/nextjs (client) 57.74 kB +0.17% +95 B 🔺
@sentry/sveltekit (client) 52.82 kB +0.18% +91 B 🔺
@sentry/core/server 43.92 kB +0.24% +103 B 🔺
@sentry/core/browser 14.02 kB +0.72% +99 B 🔺
@sentry/node 156.75 kB +0.09% +130 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.27 kB - -
@sentry/node - without tracing 96.64 kB +0.04% +37 B 🔺
@sentry/node - without channel injection 137.05 kB +0.1% +129 B 🔺
@sentry/aws-serverless 105.36 kB +0.13% +136 B 🔺
@sentry/cloudflare (withSentry) - minified 200.45 kB +0.18% +355 B 🔺
@sentry/cloudflare (withSentry) 498.12 kB +0.22% +1.06 kB 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 222.31 kB +0.16% +355 B 🔺

View base workflow run

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 6 not successful, 50 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Failing after 41s Details
❌ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Failing after 59s Details
❌ CI: Optional E2E Tests / E2E nextjs-16-cacheComponents (cloudflare) Test (optional) Failing after 10m Details
❌ CI: Optional E2E Tests / E2E node-eve Test (optional) Failing after 2m Details
❌ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Failing after 2m Details
❌ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Failing after 39s Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 11m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 59s Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 42s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 10m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 50s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 54s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (tunnel-dev) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 10m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 49s Details

This branch has not been deployed

No deployments
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.

Span streaming: a child span keeps an old sentry.segment.name when the root span is renamed after the child ends

1 participant