Skip to content

Commit 587e3e8

Browse files
committed
set web vitals as attributes in span-first
1 parent 9c1fe8c commit 587e3e8

File tree

2 files changed

+7
-1
lines changed
  • dev-packages/browser-integration-tests/suites/span-first/linked-traces
  • packages/browser-utils/src/metrics

2 files changed

+7
-1
lines changed

dev-packages/browser-integration-tests/suites/span-first/linked-traces/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from '@playwright/test';
22
import { SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from '@sentry/core';
33
import { sentryTest } from '../../../utils/fixtures';
4-
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../utils/helpers';
4+
import { shouldSkipTracingTest } from '../../../utils/helpers';
55
import { getSpanOp, waitForV2Spans } from '../../../utils/spanFirstUtils';
66

77
sentryTest("navigation spans link back to previous trace's root span", async ({ getLocalTestUrl, page }) => {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Client, Measurements, Span, SpanAttributes, SpanAttributeValue, St
33
import {
44
browserPerformanceTimeOrigin,
55
getActiveSpan,
6+
getClient,
67
getComponentName,
78
htmlTreeAsString,
89
isPrimitive,
@@ -402,7 +403,12 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
402403
delete _measurements.lcp;
403404
}
404405

406+
const isSpanFirst = getClient()?.getOptions().traceLifecycle === 'stream';
405407
Object.entries(_measurements).forEach(([measurementName, measurement]) => {
408+
if (isSpanFirst) {
409+
span.setAttribute(`ui.web_vital.${measurementName}`, measurement.value);
410+
return;
411+
}
406412
setMeasurement(measurementName, measurement.value, measurement.unit);
407413
});
408414

0 commit comments

Comments
 (0)