Skip to content

Commit 0c36564

Browse files
authored
ref(browser): Ensure start time of interaction root and child span is 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.
1 parent fa684ab commit 0c36564

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ export function startTrackingLongAnimationFrames(): void {
200200
*/
201201
export function startTrackingInteractions(): void {
202202
addPerformanceInstrumentationHandler('event', ({ entries }) => {
203-
if (!getActiveSpan()) {
203+
const parent = getActiveSpan();
204+
if (!parent) {
204205
return;
205206
}
206207
for (const entry of entries) {
@@ -222,10 +223,7 @@ export function startTrackingInteractions(): void {
222223
spanOptions.attributes['ui.component_name'] = componentName;
223224
}
224225

225-
const span = startInactiveSpan(spanOptions);
226-
if (span) {
227-
span.end(startTime + duration);
228-
}
226+
startAndEndSpan(parent, startTime, startTime + duration, spanOptions);
229227
}
230228
}
231229
});

0 commit comments

Comments
 (0)