Skip to content

Commit 8a92d0d

Browse files
msonnbcodex
andauthored
test(browser): port browser tracing suites to span streaming (#24888)
Exercise browserTracingIntegration with default span streaming, including low-cardinality names and children sent across envelopes. Retain the existing transaction counterparts as explicitly pinned `*-static` suites to preserve compatibility coverage for navigation, pageloads, linked traces, timing, and sampling. Stacked on #24881 for the shared span collector and dynamic sampling context helpers. Fixes #24142 --------- Co-authored-by: GPT-6 <codex@openai.com>
1 parent 40e0275 commit 8a92d0d

212 files changed

Lines changed: 3526 additions & 3240 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/async-spans/init.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Sentry from '@sentry/browser';
33
window.Sentry = Sentry;
44

55
Sentry.init({
6-
traceLifecycle: 'static',
76
dsn: 'https://public@dsn.ingest.sentry.io/1337',
87
integrations: [Sentry.browserTracingIntegration()],
98
tracesSampleRate: 1,

‎dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/async-spans/test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
import type { Event } from '@sentry/core';
32
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers';
3+
import { shouldSkipTracingTest } from '../../../../utils/helpers';
54

65
type WindowWithSpan = Window & {
76
firstWaitingSpan: any;
@@ -19,8 +18,7 @@ sentryTest(
1918
const url = await getLocalTestUrl({ testDir: __dirname });
2019
await page.goto(url);
2120

22-
const envelope = await getFirstSentryEnvelopeRequest<Event>(page);
23-
expect(envelope).toBeDefined();
21+
await page.waitForFunction(() => !!(window as unknown as WindowWithSpan).secondWaitingSpan);
2422

2523
const firstWaitingSpanValue = await page.evaluate(
2624
() => (window as unknown as WindowWithSpan).firstWaitingSpan.name,

‎dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-custom/init.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Sentry from '@sentry/browser';
33
window.Sentry = Sentry;
44

55
Sentry.init({
6-
traceLifecycle: 'static',
76
dsn: 'https://public@dsn.ingest.sentry.io/1337',
87
integrations: [
98
Sentry.browserTracingIntegration({

‎dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-custom/test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { SENTRY_STATUS_MESSAGE, SENTRY_CANCELLATION_REASON } from '@sentry/conventions/attributes';
12
import { expect } from '@playwright/test';
23
import type { StreamedSpanJSON } from '@sentry/core';
34
import { sentryTest } from '../../../../utils/fixtures';
45
import { shouldSkipTracingTest } from '../../../../utils/helpers';
56

6-
sentryTest('should finish a custom transaction when the page goes background', async ({ getLocalTestUrl, page }) => {
7+
sentryTest('should finish a custom span when the page goes background', async ({ getLocalTestUrl, page }) => {
78
if (shouldSkipTracingTest()) {
89
sentryTest.skip();
910
}
@@ -32,6 +33,6 @@ sentryTest('should finish a custom transaction when the page goes background', a
3233
expect(name_after).toBe(name_before);
3334
// a cancelled span is reported as `ok`, with the raw status kept as an attribute
3435
expect(spanJsonAfter.status).toBe('ok');
35-
expect(attributes_after['sentry.status.message']).toBeUndefined();
36-
expect(attributes_after['sentry.cancellation_reason']).toBe('document.hidden');
36+
expect(attributes_after[SENTRY_STATUS_MESSAGE]).toBeUndefined();
37+
expect(attributes_after[SENTRY_CANCELLATION_REASON]).toBe('document.hidden');
3738
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/navigation-streamed/init.js renamed to dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-pageload-static/init.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import * as Sentry from '@sentry/browser';
33
window.Sentry = Sentry;
44

55
Sentry.init({
6+
traceLifecycle: 'static',
67
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7-
integrations: [Sentry.browserTracingIntegration(), Sentry.spanStreamingIntegration()],
8+
integrations: [Sentry.browserTracingIntegration()],
89
tracesSampleRate: 1,
910
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-pageload-streamed/subject.js renamed to dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-pageload-static/subject.js

File renamed without changes.

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-pageload-streamed/template.html renamed to dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-pageload-static/template.html

File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { PAGELOAD } from '@sentry/conventions/op';
2+
import { SENTRY_CANCELLATION_REASON } from '@sentry/conventions/attributes';
3+
import { expect } from '@playwright/test';
4+
import { sentryTest } from '../../../../utils/fixtures';
5+
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../utils/helpers';
6+
7+
sentryTest('should finish pageload transaction when the page goes background', async ({ getLocalTestUrl, page }) => {
8+
if (shouldSkipTracingTest()) {
9+
sentryTest.skip();
10+
}
11+
const url = await getLocalTestUrl({ testDir: __dirname });
12+
13+
const pageloadPromise = waitForTransactionRequest(page, event => event.contexts?.trace?.op === PAGELOAD);
14+
15+
await page.goto(url);
16+
await page.locator('#go-background').click();
17+
18+
const pageloadTransaction = envelopeRequestParser(await pageloadPromise);
19+
20+
expect(pageloadTransaction.contexts?.trace?.op).toBe(PAGELOAD);
21+
expect(pageloadTransaction.contexts?.trace?.status).toBe('cancelled');
22+
expect(pageloadTransaction.contexts?.trace?.data?.[SENTRY_CANCELLATION_REASON]).toBe('document.hidden');
23+
});

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces-streamed/session-storage/init.js renamed to dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-pageload/init.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ window.Sentry = Sentry;
44

55
Sentry.init({
66
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7-
integrations: [
8-
Sentry.browserTracingIntegration({ linkPreviousTrace: 'session-storage' }),
9-
Sentry.spanStreamingIntegration(),
10-
],
7+
integrations: [Sentry.browserTracingIntegration()],
118
tracesSampleRate: 1,
129
});

0 commit comments

Comments
 (0)