-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathscenario.mjs
More file actions
50 lines (45 loc) · 1.49 KB
/
scenario.mjs
File metadata and controls
50 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as Sentry from '@sentry/node';
import http from 'http';
async function run() {
const traceData = Sentry.getTraceData();
// fetch with manual getTraceData() headers - the core reproduction case from #19158
await fetch(`${process.env.SERVER_URL}/api/fetch-custom-headers`, {
headers: {
...traceData,
'x-tracedata-sentry-trace': traceData['sentry-trace'],
'x-tracedata-baggage': traceData.baggage,
},
}).then(res => res.text());
// fetch without manual headers (baseline - auto-instrumentation only)
await fetch(`${process.env.SERVER_URL}/api/fetch`, {
headers: {
'x-tracedata-sentry-trace': traceData['sentry-trace'],
'x-tracedata-baggage': traceData.baggage,
},
}).then(res => res.text());
// http.request with manual getTraceData() headers
await new Promise((resolve, reject) => {
const url = new URL(`${process.env.SERVER_URL}/api/http-custom-headers`);
const req = http.request(
{
hostname: url.hostname,
port: url.port,
path: url.pathname,
method: 'GET',
headers: {
...traceData,
'x-tracedata-sentry-trace': traceData['sentry-trace'],
'x-tracedata-baggage': traceData.baggage,
},
},
res => {
res.on('data', () => {});
res.on('end', () => resolve());
},
);
req.on('error', reject);
req.end();
});
Sentry.captureException(new Error('done'));
}
Sentry.startSpan({ name: 'parent_span' }, () => run());