Skip to content

Commit 861710d

Browse files
nicohrubeccodex
andauthored
test(node): Port fetch request suites to span streaming (#25189)
Run the fetch request suites with the default span-streaming lifecycle. Part of #24135 --------- Co-authored-by: GPT-6 <codex@openai.com>
1 parent ee6df73 commit 861710d

7 files changed

Lines changed: 25 additions & 11 deletions

File tree

‎dev-packages/node-integration-tests/suites/tracing/requests/fetch-breadcrumbs/instrument.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
22
import { loggingTransport } from '@sentry-internal/node-integration-tests';
33

44
Sentry.init({
5-
traceLifecycle: 'static',
65
dsn: 'https://public@dsn.ingest.sentry.io/1337',
76
release: '1.0',
87
tracePropagationTargets: [/\/v0/, 'v1'],

‎dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-trace-propagation/instrument.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
22
import { loggingTransport } from '@sentry-internal/node-integration-tests';
33

44
Sentry.init({
5-
traceLifecycle: 'static',
65
dsn: 'https://public@dsn.ingest.sentry.io/1337',
76
release: '1.0',
87
integrations: [Sentry.nativeNodeFetchIntegration({ tracePropagation: false })],

‎dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/instrument.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
22
import { loggingTransport } from '@sentry-internal/node-integration-tests';
33

44
Sentry.init({
5-
traceLifecycle: 'static',
65
dsn: 'https://public@dsn.ingest.sentry.io/1337',
76
release: '1.0',
87
tracePropagationTargets: [/\/v0/, 'v1'],

‎dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/instrument.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
22
import { loggingTransport } from '@sentry-internal/node-integration-tests';
33

44
Sentry.init({
5-
traceLifecycle: 'static',
65
dsn: 'https://public@dsn.ingest.sentry.io/1337',
76
release: '1.0',
87
tracePropagationTargets: [/\/v0/, 'v1'],

‎dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/instrument.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
22
import { loggingTransport } from '@sentry-internal/node-integration-tests';
33

44
Sentry.init({
5-
traceLifecycle: 'static',
65
dsn: 'https://public@dsn.ingest.sentry.io/1337',
76
release: '1.0',
87
tracePropagationTargets: [/\/v0/, 'v1'],

‎dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
import { SENTRY_OP, URL_FULL } from '@sentry/conventions/attributes';
2+
import { HTTP_CLIENT } from '@sentry/conventions/op';
13
import { createTestServer } from '@sentry-internal/test-utils';
24
import { describe, expect } from 'vitest';
35
import { createEsmAndCjsTests } from '../../../../utils/runner';
46

57
describe('outgoing fetch', () => {
68
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => {
79
test('outgoing sampled fetch requests without active span are correctly instrumented', async () => {
8-
expect.assertions(11);
10+
expect.assertions(21);
911

1012
const [SERVER_URL, closeTestServer] = await createTestServer()
1113
.get('/api/v0', headers => {
1214
expect(headers['baggage']).toEqual(expect.any(String));
13-
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/));
14-
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0');
15+
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/));
16+
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1');
1517
})
1618
.get('/api/v1', headers => {
1719
expect(headers['baggage']).toEqual(expect.any(String));
18-
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/));
19-
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0');
20+
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/));
21+
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1');
2022
})
2123
.get('/api/v2', headers => {
2224
expect(headers['baggage']).toBeUndefined();
@@ -30,6 +32,7 @@ describe('outgoing fetch', () => {
3032

3133
await createRunner()
3234
.withEnv({ SERVER_URL })
35+
.unordered()
3336
.expect({
3437
event: {
3538
exception: {
@@ -42,6 +45,23 @@ describe('outgoing fetch', () => {
4245
},
4346
},
4447
})
48+
.expect({
49+
span: container => {
50+
const spans = container.items;
51+
expect(spans).toHaveLength(4);
52+
expect(spans.map(span => span.attributes[URL_FULL]?.value).sort()).toEqual([
53+
`${SERVER_URL}/api/v0`,
54+
`${SERVER_URL}/api/v1`,
55+
`${SERVER_URL}/api/v2`,
56+
`${SERVER_URL}/api/v3`,
57+
]);
58+
59+
for (const span of spans) {
60+
expect(span.attributes[SENTRY_OP]?.value).toBe(HTTP_CLIENT);
61+
expect(span.is_segment).toBe(true);
62+
}
63+
},
64+
})
4565
.start()
4666
.completed();
4767
closeTestServer();

‎dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/instrument.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
22
import { loggingTransport } from '@sentry-internal/node-integration-tests';
33

44
Sentry.init({
5-
traceLifecycle: 'static',
65
dsn: 'https://public@dsn.ingest.sentry.io/1337',
76
release: '1.0',
87
tracePropagationTargets: [/\/v0/, 'v1'],

0 commit comments

Comments
 (0)