Skip to content

Commit 53d4981

Browse files
msonnbcodex
andcommitted
test(e2e): Migrate Effect to span streaming
Co-Authored-By: GPT-6 <codex@openai.com>
1 parent 37118dd commit 53d4981

6 files changed

Lines changed: 130 additions & 206 deletions

File tree

‎dev-packages/e2e-tests/test-applications/effect-3-node/src/app.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { createServer } from 'http';
1010

1111
const SentryLive = Layer.mergeAll(
1212
Sentry.effectLayer({
13-
traceLifecycle: 'static',
1413
dsn: process.env.E2E_TEST_DSN,
1514
environment: 'qa',
1615
debug: !!process.env.DEBUG,
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { expect, test } from '@playwright/test';
2+
import { collectStreamedSpans, getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
3+
4+
['test-success', 'test-error'].forEach(route => {
5+
test(`Sends an HTTP segment for ${route}`, async ({ baseURL }) => {
6+
const spanPromise = waitForStreamedSpan(
7+
'effect-3-node',
8+
span =>
9+
span.is_segment && getSpanOp(span) === 'http.server' && span.attributes['url.path']?.value === `/${route}`,
10+
);
11+
12+
await fetch(`${baseURL}/${route}`);
13+
14+
const span = await spanPromise;
15+
expect(span.name).toBe('http.server GET');
16+
expect(span.attributes['sentry.origin']?.value).toBe('auto.http.effect');
17+
});
18+
});
19+
20+
test('Sends a manual Effect span', async ({ baseURL }) => {
21+
const spansPromise = collectStreamedSpans(
22+
'effect-3-node',
23+
spans =>
24+
spans.some(span => span.is_segment && getSpanOp(span) === 'http.server') &&
25+
spans.some(span => span.name === 'test-span'),
26+
);
27+
28+
await fetch(`${baseURL}/test-transaction`);
29+
30+
const spans = await spansPromise;
31+
const segment = spans.find(span => span.is_segment)!;
32+
const children = spans.filter(span => !span.is_segment);
33+
expect(segment.name).toBe('http.server GET');
34+
expect(children).toHaveLength(1);
35+
expect(children[0]).toMatchObject({ name: 'test-span', parent_span_id: segment.span_id });
36+
});
37+
38+
test('Sends Effect spans with correct parent-child structure', async ({ baseURL }) => {
39+
const spansPromise = collectStreamedSpans(
40+
'effect-3-node',
41+
spans =>
42+
spans.some(span => span.is_segment && getSpanOp(span) === 'http.server') &&
43+
spans.some(span => span.name === 'custom-effect-span') &&
44+
spans.some(span => span.name === 'nested-span'),
45+
);
46+
47+
await fetch(`${baseURL}/test-effect-span`);
48+
49+
const spans = await spansPromise;
50+
const segment = spans.find(span => span.is_segment)!;
51+
const children = spans.filter(span => !span.is_segment);
52+
expect(segment.name).toBe('http.server GET');
53+
expect(segment.attributes['sentry.origin']?.value).toBe('auto.http.effect');
54+
expect(segment.attributes['sentry.sdk.name']?.value).toBe('sentry.javascript.effect');
55+
expect(children).toHaveLength(2);
56+
const parent = children.find(span => span.name === 'custom-effect-span')!;
57+
const nested = children.find(span => span.name === 'nested-span')!;
58+
expect(parent.parent_span_id).toBe(segment.span_id);
59+
expect(nested.parent_span_id).toBe(parent.span_id);
60+
for (const child of children) {
61+
expect(getSpanOp(child)).toBe('function');
62+
expect(child.attributes['sentry.origin']?.value).toBe('auto.function.effect');
63+
expect(child.trace_id).toBe(segment.trace_id);
64+
}
65+
});

‎dev-packages/e2e-tests/test-applications/effect-3-node/tests/transactions.test.ts‎

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

‎dev-packages/e2e-tests/test-applications/effect-4-node/src/app.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { createServer } from 'http';
1111

1212
const SentryLive = Layer.mergeAll(
1313
Sentry.effectLayer({
14-
traceLifecycle: 'static',
1514
dsn: process.env.E2E_TEST_DSN,
1615
environment: 'qa',
1716
debug: !!process.env.DEBUG,
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { expect, test } from '@playwright/test';
2+
import { collectStreamedSpans, getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';
3+
4+
['test-success', 'test-error'].forEach(route => {
5+
test(`Sends an HTTP segment for ${route}`, async ({ baseURL }) => {
6+
const spanPromise = waitForStreamedSpan(
7+
'effect-4-node',
8+
span =>
9+
span.is_segment && getSpanOp(span) === 'http.server' && span.attributes['url.path']?.value === `/${route}`,
10+
);
11+
12+
await fetch(`${baseURL}/${route}`);
13+
14+
const span = await spanPromise;
15+
expect(span.name).toBe('http.server GET');
16+
expect(span.attributes['sentry.origin']?.value).toBe('auto.http.effect');
17+
});
18+
});
19+
20+
test('Sends a manual Effect span', async ({ baseURL }) => {
21+
const spansPromise = collectStreamedSpans(
22+
'effect-4-node',
23+
spans =>
24+
spans.some(span => span.is_segment && getSpanOp(span) === 'http.server') &&
25+
spans.some(span => span.name === 'test-span'),
26+
);
27+
28+
await fetch(`${baseURL}/test-transaction`);
29+
30+
const spans = await spansPromise;
31+
const segment = spans.find(span => span.is_segment)!;
32+
const children = spans.filter(span => !span.is_segment);
33+
expect(segment.name).toBe('http.server GET');
34+
expect(children).toHaveLength(1);
35+
expect(children[0]).toMatchObject({ name: 'test-span', parent_span_id: segment.span_id });
36+
});
37+
38+
test('Sends Effect spans with correct parent-child structure', async ({ baseURL }) => {
39+
const spansPromise = collectStreamedSpans(
40+
'effect-4-node',
41+
spans =>
42+
spans.some(span => span.is_segment && getSpanOp(span) === 'http.server') &&
43+
spans.some(span => span.name === 'custom-effect-span') &&
44+
spans.some(span => span.name === 'nested-span'),
45+
);
46+
47+
await fetch(`${baseURL}/test-effect-span`);
48+
49+
const spans = await spansPromise;
50+
const segment = spans.find(span => span.is_segment)!;
51+
const children = spans.filter(span => !span.is_segment);
52+
expect(segment.name).toBe('http.server GET');
53+
expect(segment.attributes['sentry.origin']?.value).toBe('auto.http.effect');
54+
expect(segment.attributes['sentry.sdk.name']?.value).toBe('sentry.javascript.effect');
55+
expect(children).toHaveLength(2);
56+
const parent = children.find(span => span.name === 'custom-effect-span')!;
57+
const nested = children.find(span => span.name === 'nested-span')!;
58+
expect(parent.parent_span_id).toBe(segment.span_id);
59+
expect(nested.parent_span_id).toBe(parent.span_id);
60+
for (const child of children) {
61+
expect(getSpanOp(child)).toBe('function');
62+
expect(child.attributes['sentry.origin']?.value).toBe('auto.function.effect');
63+
expect(child.trace_id).toBe(segment.trace_id);
64+
}
65+
});

‎dev-packages/e2e-tests/test-applications/effect-4-node/tests/transactions.test.ts‎

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

0 commit comments

Comments
 (0)