Skip to content

feat(sdk): Migrate frontend to span streaming#116466

Draft
vgrozdanic wants to merge 2 commits into
masterfrom
feat/span-streaming-migration
Draft

feat(sdk): Migrate frontend to span streaming#116466
vgrozdanic wants to merge 2 commits into
masterfrom
feat/span-streaming-migration

Conversation

@vgrozdanic
Copy link
Copy Markdown
Member

Switch from transaction-based trace lifecycle to span streaming, where spans are sent individually as they complete instead of being batched into a transaction at the end. This gives lower latency span delivery and per-span processing.

SDK changes (initializeSdk.tsx):

  • Add spanStreamingIntegration() as the first integration (before browserTracingIntegration)
  • Replace beforeSendTransaction with beforeSendSpan wrapped in withStreamedSpan() for normalizing pageload/navigation span names via normalizeUrl
  • Replace in-callback span description filtering with the ignoreSpans SDK option (amplitude.com, pendo.io, reload.getsentry.net)
  • Remove addExtraMeasurements and addUIElementTag — these are transaction-level batch operations that examine all spans collectively and cannot work per-span in streaming mode. They remain exported from performanceForSentry but are now unused from initializeSdk

Profiling migration (commonInitialization.tsx, types/system.tsx):

  • Replace legacy profilesSampleRate with v2 profileSessionSampleRate in dev mode override and Config type. The legacy option conflicts with v2 — if both are set, the SDK ignores profileSessionSampleRate

SDK upgrade (package.json):

  • @sentry/core, @sentry/react, @sentry/node, @sentry/profiling-node: 10.41.0-beta.010.55.0 (span streaming requires >=10.53.1)

Switch from transaction-based trace lifecycle to span streaming, where
spans are sent individually as they complete instead of being batched
into a transaction at the end.

- Add spanStreamingIntegration() to enable streamed span delivery
- Replace beforeSendTransaction with beforeSendSpan + withStreamedSpan
  for route name normalization on pageload/navigation spans
- Replace span description filtering with ignoreSpans SDK option
- Migrate legacy profilesSampleRate to v2 profileSessionSampleRate
- Upgrade @sentry/core, @sentry/react, @sentry/node, and
  @sentry/profiling-node from 10.41.0-beta.0 to 10.55.0

Note: addExtraMeasurements and addUIElementTag (transaction-level batch
operations) cannot work per-span in streaming mode and are now unused
from initializeSdk. They remain exported from performanceForSentry for
any other consumers.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.59%

Remove addExtraMeasurements, addUIElementTag, and their private helpers
(addAssetMeasurements, addCustomMeasurements, addSlowAppInit) which are
no longer called after the span streaming migration. These functions
operated on TransactionEvent objects and cannot work per-span.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Comment on lines -330 to -338
transaction.measurements[`${ASSET_MEASUREMENT_ALL}.encoded`] = {
value: allEncoded,
unit: 'byte',
};
transaction.measurements[`${ASSET_MEASUREMENT_ALL}.transfer`] = {
value: allTransfered,
unit: 'byte',
};
transaction.tags.hasAnyAssetTimings = hasAssetTimings;
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 don't have to delete this. We can set the measurements as attributes on the segment span so that they can be queryable via span metrics. wdyt?

}
}

transaction.measurements = measurements;
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.

neither these. though I wonder why we do special stuff for ttfb. It's recorded by the SDK by default

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

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants