Skip to content

Commit ae2cfb0

Browse files
committed
rename to ignorePerformanceApiSpans
1 parent 6f9f306 commit ae2cfb0

5 files changed

Lines changed: 41 additions & 17 deletions

File tree

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/ignoreMeasureSpans/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Sentry.init({
66
dsn: 'https://public@dsn.ingest.sentry.io/1337',
77
integrations: [
88
Sentry.browserTracingIntegration({
9-
ignoreMeasureSpans: ['measure-ignore', /mark-i/],
9+
ignorePerformanceApiSpans: ['measure-ignore', /mark-i/],
1010
idleTimeout: 9000,
1111
}),
1212
],

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/ignoreMeasureSpans/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { sentryTest } from '../../../../utils/fixtures';
44
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../utils/helpers';
55

66
sentryTest(
7-
'should ignore mark and measure spans that match `ignoreMeasureSpans`',
7+
'should ignore mark and measure spans that match `ignorePerformanceApiSpans`',
88
async ({ getLocalTestUrl, page }) => {
99
if (shouldSkipTracingTest()) {
1010
sentryTest.skip();

packages/browser-utils/src/metrics/browserMetrics.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,13 @@ interface AddPerformanceEntriesOptions {
310310
ignoreResourceSpans: Array<'resouce.script' | 'resource.css' | 'resource.img' | 'resource.other' | string>;
311311

312312
/**
313-
* Performance spans created from `performance.mark(...)` or `performance.measure(...)`
313+
* Performance spans created from browser Performance APIs,
314+
* `performance.mark(...)` nand `performance.measure(...)`
314315
* with `name`s matching strings in the array will not be emitted.
315316
*
316317
* Default: []
317318
*/
318-
ignoreMeasureSpans: Array<string | RegExp>;
319+
ignorePerformanceApiSpans: Array<string | RegExp>;
319320
}
320321

321322
/** Add performance related spans to a transaction */
@@ -355,7 +356,7 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
355356
case 'mark':
356357
case 'paint':
357358
case 'measure': {
358-
_addMeasureSpans(span, entry, startTime, duration, timeOrigin, options.ignoreMeasureSpans);
359+
_addMeasureSpans(span, entry, startTime, duration, timeOrigin, options.ignorePerformanceApiSpans);
359360

360361
// capture web vitals
361362
const firstHidden = getVisibilityWatcher();
@@ -449,9 +450,12 @@ export function _addMeasureSpans(
449450
startTime: number,
450451
duration: number,
451452
timeOrigin: number,
452-
ignoreMeasureSpans: AddPerformanceEntriesOptions['ignoreMeasureSpans'],
453+
ignorePerformanceApiSpans: AddPerformanceEntriesOptions['ignorePerformanceApiSpans'],
453454
): void {
454-
if (['mark', 'measure'].includes(entry.entryType) && stringMatchesSomePattern(entry.name, ignoreMeasureSpans)) {
455+
if (
456+
['mark', 'measure'].includes(entry.entryType) &&
457+
stringMatchesSomePattern(entry.name, ignorePerformanceApiSpans)
458+
) {
455459
return;
456460
}
457461

packages/browser-utils/test/browser/browserMetrics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('_addMeasureSpans', () => {
117117
expect(spans).toHaveLength(0);
118118
});
119119

120-
it('ignores performance spans that match ignoreMeasureSpans', () => {
120+
it('ignores performance spans that match ignorePerformanceApiSpans', () => {
121121
const pageloadSpan = new SentrySpan({ op: 'pageload', name: '/', sampled: true });
122122
const spans: Span[] = [];
123123

packages/browser/src/tracing/browserTracingIntegration.ts

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,39 @@ export interface BrowserTracingOptions {
152152
ignoreResourceSpans: Array<'resouce.script' | 'resource.css' | 'resource.img' | 'resource.other' | string>;
153153

154154
/**
155-
* Spans created from
156-
* [`performance.mark(...)`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark)
157-
* and
158-
* [`performance.measure(...)`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)
159-
* calls will not be emitted if their names match strings in this array.
155+
* Spans created from the following browser Performance APIs,
156+
*
157+
* - [`performance.mark(...)`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark)
158+
* - [`performance.measure(...)`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)
159+
*
160+
* will not be emitted if their names match strings in this array.
160161
*
161162
* This is useful, if you come across `mark` or `measure` spans in your Sentry traces
162163
* that you want to ignore. For example, sometimes, browser extensions or libraries
163164
* emit these entries on their own, which might not be relevant to your application.
164165
*
166+
* * @example
167+
* ```ts
168+
* Sentry.init({
169+
* integrations: [
170+
* Sentry.browserTracingIntegration({
171+
* ignorePerformanceApiSpans: ['myMeasurement', /myMark/],
172+
* }),
173+
* ],
174+
* });
175+
*
176+
* // no spans will be created for these:
177+
* performance.mark('myMark');
178+
* performance.measure('myMeasurement');
179+
*
180+
* // spans will be created for these:
181+
* performance.mark('authenticated');
182+
* performance.measure('input-duration', ...);
183+
* ```
184+
*
165185
* Default: [] - By default, all `mark` and `measure` entries are sent as spans.
166186
*/
167-
ignoreMeasureSpans: Array<string | RegExp>;
187+
ignorePerformanceApiSpans: Array<string | RegExp>;
168188

169189
/**
170190
* Link the currently started trace to a previous trace (e.g. a prior pageload, navigation or
@@ -249,7 +269,7 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = {
249269
enableLongAnimationFrame: true,
250270
enableInp: true,
251271
ignoreResourceSpans: [],
252-
ignoreMeasureSpans: [],
272+
ignorePerformanceApiSpans: [],
253273
linkPreviousTrace: 'in-memory',
254274
consistentTraceSampling: false,
255275
_experiments: {},
@@ -293,7 +313,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
293313
shouldCreateSpanForRequest,
294314
enableHTTPTimings,
295315
ignoreResourceSpans,
296-
ignoreMeasureSpans,
316+
ignorePerformanceApiSpans,
297317
instrumentPageLoad,
298318
instrumentNavigation,
299319
linkPreviousTrace,
@@ -339,7 +359,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
339359
addPerformanceEntries(span, {
340360
recordClsOnPageloadSpan: !enableStandaloneClsSpans,
341361
ignoreResourceSpans,
342-
ignoreMeasureSpans,
362+
ignorePerformanceApiSpans,
343363
});
344364
setActiveIdleSpan(client, undefined);
345365

0 commit comments

Comments
 (0)