Skip to content

Commit 6eb57e7

Browse files
committed
fix integration tests after attribute name changes
1 parent 3936e7c commit 6eb57e7

File tree

3 files changed

+41
-19
lines changed
  • dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration
  • packages/browser-utils/src/metrics

3 files changed

+41
-19
lines changed

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/navigation-streamed/test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ sentryTest('starts a streamed navigation span on page navigation', async ({ getL
6969

7070
expect(navigationSpan).toEqual({
7171
attributes: {
72-
effectiveConnectionType: {
72+
'network.connection.effective_type': {
7373
type: 'string',
7474
value: expect.any(String),
7575
},
76-
hardwareConcurrency: {
77-
type: 'string',
78-
value: expect.any(String),
76+
'device.processor_count': {
77+
type: expect.stringMatching(/^(integer)|(double)$/),
78+
value: expect.any(Number),
79+
},
80+
'network.connection.rtt': {
81+
type: expect.stringMatching(/^(integer)|(double)$/),
82+
value: expect.any(Number),
7983
},
8084
'sentry.idle_span_finish_reason': {
8185
type: 'string',

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/pageload-streamed/test.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,34 @@ sentryTest(
6262

6363
expect(pageloadSpan).toEqual({
6464
attributes: {
65-
effectiveConnectionType: {
65+
// formerly known as 'effectiveConnectionType'
66+
'network.connection.effective_type': {
6667
type: 'string',
6768
value: expect.any(String),
6869
},
69-
hardwareConcurrency: {
70-
type: 'string',
71-
value: expect.any(String),
70+
// formerly known as 'hardwareConcurrency'
71+
'device.processor_count': {
72+
type: expect.stringMatching(/^(integer)|(double)$/),
73+
value: expect.any(Number),
7274
},
73-
'performance.activationStart': {
74-
type: 'integer',
75+
'browser.performance.navigation.activation_start': {
76+
type: expect.stringMatching(/^(integer)|(double)$/),
77+
value: expect.any(Number),
78+
},
79+
'browser.performance.time_origin': {
80+
type: expect.stringMatching(/^(integer)|(double)$/),
81+
value: expect.any(Number),
82+
},
83+
'network.connection.rtt': {
84+
type: expect.stringMatching(/^(integer)|(double)$/),
85+
value: expect.any(Number),
86+
},
87+
'browser.web_vital.ttfb.request_time': {
88+
type: expect.stringMatching(/^(integer)|(double)$/),
7589
value: expect.any(Number),
7690
},
77-
'performance.timeOrigin': {
78-
type: 'double',
91+
'browser.web_vital.ttfb.value': {
92+
type: expect.stringMatching(/^(integer)|(double)$/),
7993
value: expect.any(Number),
8094
},
8195
'sentry.idle_span_finish_reason': {

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { Client, Measurements, Span, SpanAttributes, SpanAttributeValue, StartSpanOptions } from '@sentry/core';
33
import {
44
browserPerformanceTimeOrigin,
5+
debug,
56
getActiveSpan,
67
getComponentName,
78
htmlTreeAsString,
@@ -27,7 +28,6 @@ import { getBrowserPerformanceAPI, isMeasurementValue, msToSec, startAndEndSpan
2728
import { getActivationStart } from './web-vitals/lib/getActivationStart';
2829
import { getNavigationEntry } from './web-vitals/lib/getNavigationEntry';
2930
import { getVisibilityWatcher } from './web-vitals/lib/getVisibilityWatcher';
30-
import { debug } from '@sentry/core';
3131
interface NavigatorNetworkInformation {
3232
readonly connection?: NetworkInformation;
3333
}
@@ -468,15 +468,18 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
468468
}
469469

470470
// Set timeOrigin which denotes the timestamp which to base the LCP/FCP/FP/TTFB measurements on
471-
span.setAttribute('performance.timeOrigin', timeOrigin);
471+
span.setAttribute(spanStreamingEnabled ? 'browser.performance.time_origin' : 'performance.timeOrigin', timeOrigin);
472472

473473
// In prerendering scenarios, where a page might be prefetched and pre-rendered before the user clicks the link,
474474
// the navigation starts earlier than when the user clicks it. Web Vitals should always be based on the
475475
// user-perceived time, so they are not reported from the actual start of the navigation, but rather from the
476476
// time where the user actively started the navigation, for example by clicking a link.
477477
// This is user action is called "activation" and the time between navigation and activation is stored in
478478
// the `activationStart` attribute of the "navigation" PerformanceEntry.
479-
span.setAttribute('performance.activationStart', getActivationStart());
479+
span.setAttribute(
480+
spanStreamingEnabled ? 'browser.performance.navigation.activation_start' : 'performance.activationStart',
481+
getActivationStart(),
482+
);
480483
}
481484

482485
_lcpEntry = undefined;
@@ -810,10 +813,11 @@ function _trackNavigator(span: Span, spanStreamingEnabled: boolean | undefined):
810813
}
811814

812815
if (isMeasurementValue(navigator.hardwareConcurrency)) {
813-
span.setAttribute(
814-
spanStreamingEnabled ? 'device.processor_count' : 'hardwareConcurrency',
815-
String(navigator.hardwareConcurrency),
816-
);
816+
if (spanStreamingEnabled) {
817+
span.setAttribute('device.processor_count', navigator.hardwareConcurrency);
818+
} else {
819+
span.setAttribute('hardwareConcurrency', String(navigator.hardwareConcurrency));
820+
}
817821
}
818822
}
819823

0 commit comments

Comments
 (0)