Skip to content

Commit

Permalink
ref(browser): Ensure start time of interaction root and child span is…
Browse files Browse the repository at this point in the history
… aligned (#14188)

Replace the manual span start and end calls for interaction child
spans with our `startAndEndSpan` helper.
Using `startAndEndSpan` also will adjust the root span's start time
stamp if the (in this case interaction-) child span starts earlier than
the parent span.
  • Loading branch information
Lms24 authored Nov 6, 2024
1 parent fa684ab commit 0c36564
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/browser-utils/src/metrics/browserMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export function startTrackingLongAnimationFrames(): void {
*/
export function startTrackingInteractions(): void {
addPerformanceInstrumentationHandler('event', ({ entries }) => {
if (!getActiveSpan()) {
const parent = getActiveSpan();
if (!parent) {
return;
}
for (const entry of entries) {
Expand All @@ -222,10 +223,7 @@ export function startTrackingInteractions(): void {
spanOptions.attributes['ui.component_name'] = componentName;
}

const span = startInactiveSpan(spanOptions);
if (span) {
span.end(startTime + duration);
}
startAndEndSpan(parent, startTime, startTime + duration, spanOptions);
}
}
});
Expand Down

0 comments on commit 0c36564

Please sign in to comment.