Skip to content

Commit f563eae

Browse files
authored
ref(tracing): Remove mark measurements (#5605)
Currently the JS SDK sends extra measurements though, specifically `mark.lcp`, `mark.fid`, `mark.fp`, `mark.fcp`. This is done because these measurements are being used in the Sentry front-end UI to draw lines on the span waterfall component on the transaction details page. These measurements should be removed, as they count toward a user’s custom measurement quota - hence we would be reducing the amount of custom measurements they can send and use because the SDK is setting them automatically. In addition, there is no way these measurements are ever going to be indexed, so we can’t move them to be built-in.
1 parent f411999 commit f563eae

File tree

4 files changed

+8
-15
lines changed
  • packages

4 files changed

+8
-15
lines changed

packages/integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ sentryTest('should capture a FID vital.', async ({ browserName, getLocalTestPath
2020

2121
expect(eventData.measurements).toBeDefined();
2222
expect(eventData.measurements?.fid?.value).toBeDefined();
23-
expect(eventData.measurements?.['mark.fid']?.value).toBeDefined();
2423

2524
const fidSpan = eventData.spans?.filter(({ description }) => description === 'first input delay')[0];
2625

packages/integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ sentryTest('should capture FP vital.', async ({ browserName, getLocalTestPath, p
1616
expect(eventData.measurements).toBeDefined();
1717
expect(eventData.measurements?.fp?.value).toBeDefined();
1818

19-
expect(eventData.measurements?.['mark.fp']?.value).toBeDefined();
20-
2119
const fpSpan = eventData.spans?.filter(({ description }) => description === 'first-paint')[0];
2220

2321
expect(fpSpan).toBeDefined();
@@ -32,8 +30,6 @@ sentryTest('should capture FCP vital.', async ({ getLocalTestPath, page }) => {
3230
expect(eventData.measurements).toBeDefined();
3331
expect(eventData.measurements?.fcp?.value).toBeDefined();
3432

35-
expect(eventData.measurements?.['mark.fcp']?.value).toBeDefined();
36-
3733
const fcpSpan = eventData.spans?.filter(({ description }) => description === 'first-contentful-paint')[0];
3834

3935
expect(fcpSpan).toBeDefined();

packages/integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ sentryTest('should capture a LCP vital with element details.', async ({ browserN
2222

2323
expect(eventData.measurements).toBeDefined();
2424
expect(eventData.measurements?.lcp?.value).toBeDefined();
25-
expect(eventData.measurements?.['mark.lcp']?.value).toBeDefined();
2625

2726
expect(eventData.tags?.['lcp.element']).toBe('body > img');
2827
expect(eventData.tags?.['lcp.size']).toBe(107400);

packages/tracing/src/browser/metrics/index.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,8 @@ function _trackLCP(reportAllChanges: boolean): void {
8787
return;
8888
}
8989

90-
const timeOrigin = msToSec(browserPerformanceTimeOrigin as number);
91-
const startTime = msToSec(entry.startTime);
9290
__DEBUG_BUILD__ && logger.log('[Measurements] Adding LCP');
9391
_measurements['lcp'] = { value: metric.value, unit: 'millisecond' };
94-
_measurements['mark.lcp'] = { value: timeOrigin + startTime, unit: 'second' };
9592
_lcpEntry = entry as LargestContentfulPaint;
9693
}, reportAllChanges);
9794
}
@@ -147,7 +144,7 @@ export function addPerformanceEntries(transaction: Transaction): void {
147144
case 'mark':
148145
case 'paint':
149146
case 'measure': {
150-
const startTimestamp = _addMeasureSpans(transaction, entry, startTime, duration, timeOrigin);
147+
_addMeasureSpans(transaction, entry, startTime, duration, timeOrigin);
151148

152149
// capture web vitals
153150
const firstHidden = getVisibilityWatcher();
@@ -157,12 +154,10 @@ export function addPerformanceEntries(transaction: Transaction): void {
157154
if (entry.name === 'first-paint' && shouldRecord) {
158155
__DEBUG_BUILD__ && logger.log('[Measurements] Adding FP');
159156
_measurements['fp'] = { value: entry.startTime, unit: 'millisecond' };
160-
_measurements['mark.fp'] = { value: startTimestamp, unit: 'second' };
161157
}
162158
if (entry.name === 'first-contentful-paint' && shouldRecord) {
163159
__DEBUG_BUILD__ && logger.log('[Measurements] Adding FCP');
164160
_measurements['fcp'] = { value: entry.startTime, unit: 'millisecond' };
165-
_measurements['mark.fcp'] = { value: startTimestamp, unit: 'second' };
166161
}
167162
break;
168163
}
@@ -220,14 +215,18 @@ export function addPerformanceEntries(transaction: Transaction): void {
220215
_measurements[name].value = normalizedValue;
221216
});
222217

223-
if (_measurements['mark.fid'] && _measurements['fid']) {
218+
const fidMark = _measurements['mark.fid'];
219+
if (fidMark && _measurements['fid']) {
224220
// create span for FID
225221
_startChild(transaction, {
226222
description: 'first input delay',
227-
endTimestamp: _measurements['mark.fid'].value + msToSec(_measurements['fid'].value),
223+
endTimestamp: fidMark.value + msToSec(_measurements['fid'].value),
228224
op: 'web.vitals',
229-
startTimestamp: _measurements['mark.fid'].value,
225+
startTimestamp: fidMark.value,
230226
});
227+
228+
// Delete mark.fid as we don't want it to be part of final payload
229+
delete _measurements['mark.fid'];
231230
}
232231

233232
// If FCP is not recorded we should not record the cls value

0 commit comments

Comments
 (0)