Skip to content

Commit 40e9cd1

Browse files
committed
add performance.timeOrigin attribute
1 parent 89d82c7 commit 40e9cd1

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,24 @@ sentryTest('paint web vitals values are greater than TTFB', async ({ browserName
5858
expect(fcpValue).toBeGreaterThanOrEqual(ttfbValue!);
5959
expect(fpValue).toBeGreaterThanOrEqual(ttfbValue!);
6060
});
61+
62+
sentryTest('captures time origin as span attribute', async ({ getLocalTestPath, page }) => {
63+
// Only run in chromium to ensure all vitals are present
64+
if (shouldSkipTracingTest()) {
65+
sentryTest.skip();
66+
}
67+
68+
const url = await getLocalTestPath({ testDir: __dirname });
69+
const [eventData] = await Promise.all([getFirstSentryEnvelopeRequest<Event>(page), page.goto(url)]);
70+
71+
const timeOriginAttribute = eventData.contexts?.trace?.data?.['performance.timeOrigin'];
72+
const transactionStartTimestamp = eventData.start_timestamp;
73+
74+
expect(timeOriginAttribute).toBeDefined();
75+
expect(transactionStartTimestamp).toBeDefined();
76+
77+
const delta = Math.abs(transactionStartTimestamp! - timeOriginAttribute);
78+
79+
// The delta should be less than 1ms if this flakes, we should increase the threshold
80+
expect(delta).toBeLessThanOrEqual(1);
81+
});

dev-packages/e2e-tests/test-applications/create-remix-app-v2/app/entry.client.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ Sentry.init({
2525
// Session Replay
2626
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
2727
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
28-
// tunnel: 'http://localhost:3031/', // proxy server
29-
30-
beforeSendTransaction(transaction) {
31-
console.log('beforeSendTransaction', transaction, transaction.measurements);
32-
return transaction;
33-
},
34-
35-
debug: true,
28+
tunnel: 'http://localhost:3031/', // proxy server
3629
});
3730

3831
startTransition(() => {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
381381
});
382382

383383
// Set timeOrigin which denotes the timestamp which to base the LCP/FCP/FP/TTFB measurements on
384-
span.setAttribute('web-vitals.timeOrigin', timeOrigin);
384+
span.setAttribute('performance.timeOrigin', timeOrigin);
385385

386386
_setWebVitalAttributes(span);
387387
}

0 commit comments

Comments
 (0)