Skip to content

Commit 021c8c1

Browse files
authored
ref(browser): Move navigation span descriptions into op (#13527)
Makes some modifications to `browser` spans: - Moves the description of navigation related `browser` spans into the op, e.g. `browser - cache` -> `browser.cache` - Sets the description to the `performanceEntry` objects' `names`, in this context it is the URL of the page This change is being made so that these `browser` spans can be ingested and grouped. Currently, all browser spans are grouped into a singular `browser` span, despite each of the operations that these span represent doing very different things. This will improve the experience in the Spans tab of transaction summary and span summary, since we will be able to have proper groupings for `browser` spans.
1 parent 1f898b6 commit 021c8c1

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
## Unreleased
1010

1111
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
12+
- Moved description of `browser` spans into the operation, e.g. `browser - cache` -> `browser.cache` and set the URL as
13+
the description
1214

1315
## 8.31.0
1416

dev-packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sentryTest('should add browser-related spans to pageload transaction', async ({
1212
const url = await getLocalTestPath({ testDir: __dirname });
1313

1414
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
15-
const browserSpans = eventData.spans?.filter(({ op }) => op === 'browser');
15+
const browserSpans = eventData.spans?.filter(({ op }) => op?.startsWith('browser'));
1616

1717
// Spans `domContentLoadedEvent`, `connect`, `cache` and `DNS` are not
1818
// always inside `pageload` transaction.
@@ -21,7 +21,8 @@ sentryTest('should add browser-related spans to pageload transaction', async ({
2121
['loadEvent', 'request', 'response'].forEach(eventDesc =>
2222
expect(browserSpans).toContainEqual(
2323
expect.objectContaining({
24-
description: eventDesc,
24+
op: `browser.${eventDesc}`,
25+
description: page.url(),
2526
parent_span_id: eventData.contexts?.trace?.span_id,
2627
}),
2728
),

dev-packages/browser-integration-tests/suites/tracing/metrics/pageload-measure-spans/test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ sentryTest('should add browser-related spans to pageload transaction', async ({
1313
const url = await getLocalTestPath({ testDir: __dirname });
1414

1515
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
16-
const browserSpans = eventData.spans?.filter(({ op }) => op === 'browser');
16+
const browserSpans = eventData.spans?.filter(({ op }) => op?.startsWith('browser'));
1717

1818
// Spans `domContentLoadedEvent`, `connect`, `cache` and `DNS` are not
1919
// always inside `pageload` transaction.
2020
expect(browserSpans?.length).toBeGreaterThanOrEqual(4);
2121

22-
const requestSpan = browserSpans!.find(({ description }) => description === 'request');
22+
const requestSpan = browserSpans!.find(({ op }) => op === 'browser.request');
2323
expect(requestSpan).toBeDefined();
24+
expect(requestSpan?.description).toBe(page.url());
2425

2526
const measureSpan = eventData.spans?.find(({ op }) => op === 'measure');
2627
expect(measureSpan).toBeDefined();

dev-packages/e2e-tests/test-applications/react-create-hash-router/tests/transactions.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ test('Captures a pageload transaction', async ({ page }) => {
4444
expect(transactionEvent.spans).toContainEqual({
4545
data: {
4646
'sentry.origin': 'auto.ui.browser.metrics',
47-
'sentry.op': 'browser',
47+
'sentry.op': 'browser.domContentLoadedEvent',
4848
},
49-
description: 'domContentLoadedEvent',
50-
op: 'browser',
49+
description: page.url(),
50+
op: 'browser.domContentLoadedEvent',
5151
parent_span_id: expect.any(String),
5252
span_id: expect.any(String),
5353
start_timestamp: expect.any(Number),
@@ -58,10 +58,10 @@ test('Captures a pageload transaction', async ({ page }) => {
5858
expect(transactionEvent.spans).toContainEqual({
5959
data: {
6060
'sentry.origin': 'auto.ui.browser.metrics',
61-
'sentry.op': 'browser',
61+
'sentry.op': 'browser.connect',
6262
},
63-
description: 'connect',
64-
op: 'browser',
63+
description: page.url(),
64+
op: 'browser.connect',
6565
parent_span_id: expect.any(String),
6666
span_id: expect.any(String),
6767
start_timestamp: expect.any(Number),
@@ -72,10 +72,10 @@ test('Captures a pageload transaction', async ({ page }) => {
7272
expect(transactionEvent.spans).toContainEqual({
7373
data: {
7474
'sentry.origin': 'auto.ui.browser.metrics',
75-
'sentry.op': 'browser',
75+
'sentry.op': 'browser.request',
7676
},
77-
description: 'request',
78-
op: 'browser',
77+
description: page.url(),
78+
op: 'browser.request',
7979
parent_span_id: expect.any(String),
8080
span_id: expect.any(String),
8181
start_timestamp: expect.any(Number),
@@ -86,10 +86,10 @@ test('Captures a pageload transaction', async ({ page }) => {
8686
expect(transactionEvent.spans).toContainEqual({
8787
data: {
8888
'sentry.origin': 'auto.ui.browser.metrics',
89-
'sentry.op': 'browser',
89+
'sentry.op': 'browser.response',
9090
},
91-
description: 'response',
92-
op: 'browser',
91+
description: page.url(),
92+
op: 'browser.response',
9393
parent_span_id: expect.any(String),
9494
span_id: expect.any(String),
9595
start_timestamp: expect.any(Number),

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ function _addPerformanceNavigationTiming(
470470
return;
471471
}
472472
startAndEndSpan(span, timeOrigin + msToSec(start), timeOrigin + msToSec(end), {
473-
op: 'browser',
474-
name: name || event,
473+
op: `browser.${name || event}`,
474+
name: entry.name,
475475
attributes: {
476476
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
477477
},
@@ -490,16 +490,16 @@ function _addRequest(span: Span, entry: Record<string, any>, timeOrigin: number)
490490
// In order not to produce faulty spans, where the end timestamp is before the start timestamp, we will only collect
491491
// these spans when the responseEnd value is available. The backend (Relay) would drop the entire span if it contained faulty spans.
492492
startAndEndSpan(span, requestStartTimestamp, responseEndTimestamp, {
493-
op: 'browser',
494-
name: 'request',
493+
op: 'browser.request',
494+
name: entry.name,
495495
attributes: {
496496
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
497497
},
498498
});
499499

500500
startAndEndSpan(span, responseStartTimestamp, responseEndTimestamp, {
501-
op: 'browser',
502-
name: 'response',
501+
op: 'browser.response',
502+
name: entry.name,
503503
attributes: {
504504
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
505505
},

0 commit comments

Comments
 (0)