Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinL10 committed Jun 27, 2024
1 parent a5e95d9 commit d4ff07d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 35 deletions.
47 changes: 23 additions & 24 deletions packages/browser-utils/src/metrics/browserMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,32 +124,31 @@ export function startTrackingLongTasks(): void {
* Start tracking long animation frames.
*/
export function startTrackingLongAnimationFrames(): void {
addPerformanceInstrumentationHandler('long-animation-frame', ({ entries }) => {
for (const entry of entries) {
if (!getActiveSpan()) {
return;
}
const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime);
const duration = msToSec(entry.duration);


const span = startInactiveSpan({
name: 'Main UI thread blocked',
op: 'ui.long-animation-frame',
startTime,
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
},
});
if (span) {
span.end(startTime + duration);
}
}
});
// NOTE: the current web-vitals version (3.5.2) does not support long-animation-frame, so
// we should directly observe `long-animation-frame` events here instead of through the web-vitals
// `observe` helper function.
// addPerformanceInstrumentationHandler('long-animation-frame', ({ entries }) => {
// for (const entry of entries) {
// if (!getActiveSpan()) {
// return;
// }
// const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime);
// const duration = msToSec(entry.duration);
// const span = startInactiveSpan({
// name: 'Main UI thread blocked',
// op: 'ui.long-animation-frame',
// startTime,
// attributes: {
// [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
// },
// });
// if (span) {
// span.end(startTime + duration);
// }
// }
// });
}



/**
* Start tracking interaction events.
*/
Expand Down
11 changes: 0 additions & 11 deletions packages/browser-utils/src/metrics/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { onTTFB } from './web-vitals/onTTFB';

type InstrumentHandlerTypePerformanceObserver =
| 'longtask'
| 'long-animation-frame'
| 'event'
| 'navigation'
| 'paint'
Expand All @@ -37,12 +36,6 @@ interface PerformanceEventTiming extends PerformanceEntry {
interactionId?: number;
}

interface PerformanceScriptTiming extends PerformanceEntry {
sourceCharPosition: number;
sourceFunctionName: string;
sourceUrl: string;
}

interface Metric {
/**
* The name of the metric (in acronym form).
Expand Down Expand Up @@ -169,10 +162,6 @@ export function addPerformanceInstrumentationHandler(
type: 'event',
callback: (data: { entries: ((PerformanceEntry & { target?: unknown | null }) | PerformanceEventTiming)[] }) => void,
): CleanupHandlerCallback;
export function addPerformanceInstrumentationHandler(
type: 'long-animation-frame',
callback: (data: { entries: (PerformanceEntry & {scripts?: PerformanceScriptTiming[]})[] }) => void,
): CleanupHandlerCallback;
export function addPerformanceInstrumentationHandler(
type: InstrumentHandlerTypePerformanceObserver,
callback: (data: { entries: PerformanceEntry[] }) => void,
Expand Down

0 comments on commit d4ff07d

Please sign in to comment.