Skip to content

feat(browser)!: Extract performance.{mark,measure} spans into new userTimingSpansIntegration#22554

Draft
msonnb wants to merge 2 commits into
developfrom
ms/performance-mark-measure
Draft

feat(browser)!: Extract performance.{mark,measure} spans into new userTimingSpansIntegration#22554
msonnb wants to merge 2 commits into
developfrom
ms/performance-mark-measure

Conversation

@msonnb

@msonnb msonnb commented Jul 23, 2026

Copy link
Copy Markdown
Member

What?

browserTracingIntegration no longer captures performance.mark() / performance.measure() spans by default. This behavior moves into a new opt-in userTimingSpansIntegration, and the ignorePerformanceApiSpans option is replaced by the integration's ignore option.

// before
Sentry.init({
  integrations: [
    Sentry.browserTracingIntegration({ ignorePerformanceApiSpans: ['third-party-mark'] }),
  ],
});

// after
Sentry.init({
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.userTimingSpansIntegration({ ignore: ['third-party-mark'] }),
  ],
});

Why?

User Timing spans are useful for some apps and pure noise for others (browser extensions and third-party libraries emit their own mark/measure entries). Bundling them into browserTracingIntegration meant everyone paid the bundle-size and span-volume cost whether they wanted the data or not, and the only escape hatch was an ignore-list. Making it a separate, explicitly-added integration means you opt in when you want it, and it drops out of the tree-shaken bundle when you don't.

Closes #22352

@msonnb

msonnb commented Jul 23, 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 2 potential issues.

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 5e11523. Configure here.

};

addPerformanceInstrumentationHandler('mark', handleEntries);
addPerformanceInstrumentationHandler('measure', handleEntries);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Async capture drops late spans

Medium Severity

userTimingSpansIntegration only creates spans when getActiveSpan() is set at PerformanceObserver callback time, but observe always defers that callback by a microtask. The old path collected mark/measure entries synchronously in beforeSpanEnd via performance.getEntries(), so entries that occurred during the pageload/navigation were not lost if the idle span ended in the meantime. Entries reported just before the root span ends can now be dropped.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e11523. Configure here.


const spans = await spansPromise;
const userTimingSpans = spans.filter(span => ['mark', 'measure'].includes(getSpanOp(span) ?? ''));
expect(userTimingSpans).toHaveLength(3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Streamed test wait is racy

Medium Severity

The streamed integration test resolves as soon as any envelope contains a pageload span, then asserts that mark/measure spans are in that same envelope. SpanBuffer can flush earlier on its per-trace interval or size limit, so User Timing spans may already have been sent in a previous envelope. This violates the Testing Conventions rule against race-prone waits that are not unique enough for the data under assertion.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 5e11523. Configure here.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.79 kB - -
@sentry/browser - with treeshaking flags 26.23 kB - -
@sentry/browser (incl. Tracing) 46.04 kB -0.59% -273 B 🔽
@sentry/browser (incl. Tracing + Span Streaming) 47.76 kB -0.64% -304 B 🔽
@sentry/browser (incl. Tracing, Profiling) 50.81 kB -0.6% -304 B 🔽
@sentry/browser (incl. Tracing, Replay) 85.28 kB -0.36% -308 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.94 kB -0.39% -290 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 89.99 kB -0.34% -306 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 102.66 kB -0.31% -313 B 🔽
@sentry/browser (incl. Feedback) 44.96 kB - -
@sentry/browser (incl. sendFeedback) 32.59 kB - -
@sentry/browser (incl. FeedbackAsync) 37.64 kB - -
@sentry/browser (incl. Metrics) 28.88 kB - -
@sentry/browser (incl. Logs) 29.11 kB - -
@sentry/browser (incl. Metrics & Logs) 29.8 kB - -
@sentry/react 29.59 kB - -
@sentry/react (incl. Tracing) 48.32 kB -0.59% -284 B 🔽
@sentry/vue 33.22 kB - -
@sentry/vue (incl. Tracing) 47.97 kB -0.66% -316 B 🔽
@sentry/svelte 27.81 kB - -
CDN Bundle 30.11 kB - -
CDN Bundle (incl. Tracing) 48.27 kB +0.28% +132 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.69 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.6 kB +0.28% +134 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.95 kB - -
CDN Bundle (incl. Tracing, Replay) 85.86 kB +0.18% +147 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.16 kB +0.18% +152 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.63 kB +0.16% +143 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.93 kB +0.17% +150 B 🔺
CDN Bundle - uncompressed 89.77 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.2 kB +0.25% +357 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.48 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.18 kB +0.24% +357 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.24 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.44 kB +0.14% +357 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.4 kB +0.14% +357 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.14 kB +0.13% +357 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.09 kB +0.13% +357 B 🔺
@sentry/nextjs (client) 50.86 kB -0.55% -277 B 🔽
@sentry/sveltekit (client) 46.47 kB -0.61% -284 B 🔽
@sentry/core/server 80.07 kB - -
@sentry/core/browser 51.9 kB - -
@sentry/node 124.57 kB -0.01% -1 B 🔽
@sentry/node (incl. diagnostics channel injection) 149.97 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB -0.01% -2 B 🔽
@sentry/node - without tracing 74.66 kB - -
@sentry/aws-serverless 84.13 kB -0.01% -1 B 🔽
@sentry/cloudflare (withSentry) - minified 196.61 kB - -
@sentry/cloudflare (withSentry) 483.83 kB - -

View base workflow run

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.

Stop emitting browser mark and measure spans by default

1 participant