Conversation

Lms24
  • Adds ignorePerformanceApiSpans option that matches span names of mark and measure spans to a given array or RegExp
  • Adds unit tests
  • Adds integration test

Usage:

Sentry.init({
  dsn: '...',
  integrations: [
    Sentry.browserTracingIntegration({
      ignorePerformanceApiSpans: ['measure-ignore', /mark-to-ignore/],
    }),
  ],
  tracesSampleRate: 1,
});

closes #16441

@Lms24Lms24 requested review from bcoe and s1gr1d June 2, 2025 11:57
@Lms24Lms24 self-assigned this Jun 2, 2025
@github-actionsGitHub Actions

size-limit report 📦

PathSize% ChangeChange
@sentry/browser23.99 kB--
@sentry/browser - with treeshaking flags23.76 kB--
@sentry/browser (incl. Tracing)38.34 kB+0.14%+52 B 🔺
@sentry/browser (incl. Tracing, Replay)76.48 kB+0.06%+45 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags69.59 kB+0.07%+42 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas)81.24 kB+0.06%+41 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback)93.32 kB+0.05%+44 B 🔺
@sentry/browser (incl. Feedback)40.73 kB--
@sentry/browser (incl. sendFeedback)28.7 kB--
@sentry/browser (incl. FeedbackAsync)33.59 kB--
@sentry/react25.76 kB--
@sentry/react (incl. Tracing)40.33 kB+0.1%+40 B 🔺
@sentry/vue28.34 kB--
@sentry/vue (incl. Tracing)40.18 kB+0.13%+50 B 🔺
@sentry/svelte24.01 kB--
CDN Bundle25.48 kB--
CDN Bundle (incl. Tracing)38.52 kB+0.11%+39 B 🔺
CDN Bundle (incl. Tracing, Replay)74.38 kB+0.07%+49 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)79.8 kB+0.06%+42 B 🔺
CDN Bundle - uncompressed74.41 kB--
CDN Bundle (incl. Tracing) - uncompressed114.07 kB+0.16%+179 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed228.04 kB+0.08%+179 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed240.87 kB+0.08%+179 B 🔺
@sentry/nextjs (client)42 kB+0.11%+44 B 🔺
@sentry/sveltekit (client)38.84 kB+0.12%+45 B 🔺
@sentry/node149.87 kB-0.01%-1 B 🔽
@sentry/node - without tracing98.12 kB-0.01%-1 B 🔽
@sentry/aws-serverless123.88 kB-0.01%-1 B 🔽

View base workflow run

bcoe
bcoe approved these changes Jun 2, 2025
@@ -149,7 +149,22 @@ export interface BrowserTracingOptions {
*
* Default: []
*/
ignoreResourceSpans: Array<string>;
ignoreResourceSpans: Array<'resouce.script' | 'resource.css' | 'resource.img' | 'resource.other' | string>;
Copy link
Member

Choose a reason for hiding this comment

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

Nice type addition 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, realized we only made this addition in browsermetrics.ts rather than the user-facing option. Luckily not breaking :D

*
* Default: [] - By default, all `mark` and `measure` entries are sent as spans.
*/
ignoreMeasureSpans: Array<string | RegExp>;
Copy link
Member

Choose a reason for hiding this comment

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

As this not only applies to the measure spans...should we call this ignorePerformanceAPISpans or ignoreWebPerformanceSpans? 🤔

No hard opinion on that though as my proposed name might be too wide in its description.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had exactly the same feeling. Let's make a decision fast, as I agree the name doesn't really include mark spans.

Copy link
Member

Choose a reason for hiding this comment

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

And this is how we could extend this if people need granular options:

ignorePerformanceAPISpans: {
  mark:
  measure:
  ...
}

Copy link
Member Author

@Lms24 Lms24 Jun 2, 2025

Choose a reason for hiding this comment

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

Renamed the option to ignorePerformanceApiSpans in ae2cfb0. Thanks for bringing this up!

@Lms24Lms24 merged commit ddec964 into develop Jun 3, 2025
125 checks passed
@Lms24Lms24 deleted the lms/feat-browser-ignore-performance-spans branch June 3, 2025 07:19
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Add Option to ignore mark and measure spans