Skip to content

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

Closed

Description

@sergical

SDK: @sentry/node 11.10.0, @sentry/nextjs 11.10.0 · Next.js 16.3.8

Steps to reproduce

const Sentry = require('@sentry/node');
Sentry.init({
  dsn: '…',
  tracesSampleRate: 1,
  traceLifecycle: 'stream',
  beforeSendSpan: Sentry.withStreamedSpan(span => {
    console.log(span.name, '-> segment:', span.attributes['sentry.segment.name']);
    return span;
  }),
});

Sentry.startSpan({ name: 'GET' }, root => {
  Sentry.startSpan({ name: 'early child' }, () => {});
  root.updateName('GET /users/:id');
  Sentry.startSpan({ name: 'late child' }, () => {});
});

Expected result

All three spans have the segment name GET /users/:id, the root span's final name.

Actual result

early child -> segment: GET
late child -> segment: GET /users/:id
GET /users/:id -> segment: GET /users/:id

Additional context

Each span copies the root span's name when the span is captured. If the root span is renamed later, the spans captured before the rename keep the old name.

In Next.js this happens on every page request. With span streaming on, serverSpanHooks.js renames the root span to the method ("GET") when it starts. The route is added only when a span with next.route starts. Spans that end before then (for example resolve page server component) have the segment name GET, so a search for GET /history doesn't find them.

Example trace: https://sentry-developer-experience.sentry.io/explore/traces/trace/e0173ae27e174c52837cbd4b5f81e219

Activity

  1. linear-code commented on Nov 4, 2026

    @linear-code
  2. self-assigned this
    on Nov 6, 2026
  3. chargome commented on Nov 6, 2026

    @chargome
    Member

    @xh123637 thank you, but we'll fix this internally

  4. added a commit that references this issue on Nov 10, 2026
    41d529a
  5. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #26178, which was included in the 11.12.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions