@@ -7,37 +7,27 @@ import { waitForTransaction } from '../event-proxy-server';
7
7
test ( 'Propagates trace for outgoing http requests' , async ( { baseURL } ) => {
8
8
const id = crypto . randomUUID ( ) ;
9
9
10
- const inboundTransactionPromise = waitForTransaction (
11
- 'node-nestjs-app' ,
12
- ( transactionEvent ) => {
13
- return (
14
- transactionEvent . contexts ?. trace ?. op === 'http.server' &&
15
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
16
- `/test-inbound-headers/${ id } `
17
- ) ;
18
- } ,
19
- ) ;
10
+ const inboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
11
+ return (
12
+ transactionEvent . contexts ?. trace ?. op === 'http.server' &&
13
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-inbound-headers/${ id } `
14
+ ) ;
15
+ } ) ;
20
16
21
- const outboundTransactionPromise = waitForTransaction (
22
- 'node-nestjs-app' ,
23
- ( transactionEvent ) => {
24
- return (
25
- transactionEvent . contexts ?. trace ?. op === 'http.server' &&
26
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
27
- `/test-outgoing-http/${ id } `
28
- ) ;
29
- } ,
30
- ) ;
17
+ const outboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
18
+ return (
19
+ transactionEvent . contexts ?. trace ?. op === 'http.server' &&
20
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-outgoing-http/${ id } `
21
+ ) ;
22
+ } ) ;
31
23
32
24
const { data } = await axios . get ( `${ baseURL } /test-outgoing-http/${ id } ` ) ;
33
25
34
26
const inboundTransaction = await inboundTransactionPromise ;
35
27
const outboundTransaction = await outboundTransactionPromise ;
36
28
37
29
const traceId = outboundTransaction ?. contexts ?. trace ?. trace_id ;
38
- const outgoingHttpSpan = outboundTransaction ?. spans ?. find (
39
- ( span ) => span . op === 'http.client' ,
40
- ) as SpanJSON | undefined ;
30
+ const outgoingHttpSpan = outboundTransaction ?. spans ?. find ( span => span . op === 'http.client' ) as SpanJSON | undefined ;
41
31
42
32
expect ( outgoingHttpSpan ) . toBeDefined ( ) ;
43
33
@@ -49,9 +39,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
49
39
const inboundHeaderSentryTrace = data . headers ?. [ 'sentry-trace' ] ;
50
40
const inboundHeaderBaggage = data . headers ?. [ 'baggage' ] ;
51
41
52
- expect ( inboundHeaderSentryTrace ) . toEqual (
53
- `${ traceId } -${ outgoingHttpSpanId } -1` ,
54
- ) ;
42
+ expect ( inboundHeaderSentryTrace ) . toEqual ( `${ traceId } -${ outgoingHttpSpanId } -1` ) ;
55
43
expect ( inboundHeaderBaggage ) . toBeDefined ( ) ;
56
44
57
45
const baggage = ( inboundHeaderBaggage || '' ) . split ( ',' ) ;
@@ -133,37 +121,27 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
133
121
test ( 'Propagates trace for outgoing fetch requests' , async ( { baseURL } ) => {
134
122
const id = crypto . randomUUID ( ) ;
135
123
136
- const inboundTransactionPromise = waitForTransaction (
137
- 'node-nestjs-app' ,
138
- ( transactionEvent ) => {
139
- return (
140
- transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
141
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
142
- `/test-inbound-headers/${ id } `
143
- ) ;
144
- } ,
145
- ) ;
124
+ const inboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
125
+ return (
126
+ transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
127
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-inbound-headers/${ id } `
128
+ ) ;
129
+ } ) ;
146
130
147
- const outboundTransactionPromise = waitForTransaction (
148
- 'node-nestjs-app' ,
149
- ( transactionEvent ) => {
150
- return (
151
- transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
152
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
153
- `/test-outgoing-fetch/${ id } `
154
- ) ;
155
- } ,
156
- ) ;
131
+ const outboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
132
+ return (
133
+ transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
134
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-outgoing-fetch/${ id } `
135
+ ) ;
136
+ } ) ;
157
137
158
138
const { data } = await axios . get ( `${ baseURL } /test-outgoing-fetch/${ id } ` ) ;
159
139
160
140
const inboundTransaction = await inboundTransactionPromise ;
161
141
const outboundTransaction = await outboundTransactionPromise ;
162
142
163
143
const traceId = outboundTransaction ?. contexts ?. trace ?. trace_id ;
164
- const outgoingHttpSpan = outboundTransaction ?. spans ?. find (
165
- ( span ) => span . op === 'http.client' ,
166
- ) as SpanJSON | undefined ;
144
+ const outgoingHttpSpan = outboundTransaction ?. spans ?. find ( span => span . op === 'http.client' ) as SpanJSON | undefined ;
167
145
168
146
expect ( outgoingHttpSpan ) . toBeDefined ( ) ;
169
147
@@ -175,9 +153,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
175
153
const inboundHeaderSentryTrace = data . headers ?. [ 'sentry-trace' ] ;
176
154
const inboundHeaderBaggage = data . headers ?. [ 'baggage' ] ;
177
155
178
- expect ( inboundHeaderSentryTrace ) . toEqual (
179
- `${ traceId } -${ outgoingHttpSpanId } -1` ,
180
- ) ;
156
+ expect ( inboundHeaderSentryTrace ) . toEqual ( `${ traceId } -${ outgoingHttpSpanId } -1` ) ;
181
157
expect ( inboundHeaderBaggage ) . toBeDefined ( ) ;
182
158
183
159
const baggage = ( inboundHeaderBaggage || '' ) . split ( ',' ) ;
@@ -256,30 +232,20 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
256
232
} ) ;
257
233
} ) ;
258
234
259
- test ( 'Propagates trace for outgoing external http requests' , async ( {
260
- baseURL,
261
- } ) => {
262
- const inboundTransactionPromise = waitForTransaction (
263
- 'node-nestjs-app' ,
264
- ( transactionEvent ) => {
265
- return (
266
- transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
267
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
268
- `/test-outgoing-http-external-allowed`
269
- ) ;
270
- } ,
271
- ) ;
235
+ test ( 'Propagates trace for outgoing external http requests' , async ( { baseURL } ) => {
236
+ const inboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
237
+ return (
238
+ transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
239
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-outgoing-http-external-allowed`
240
+ ) ;
241
+ } ) ;
272
242
273
- const { data } = await axios . get (
274
- `${ baseURL } /test-outgoing-http-external-allowed` ,
275
- ) ;
243
+ const { data } = await axios . get ( `${ baseURL } /test-outgoing-http-external-allowed` ) ;
276
244
277
245
const inboundTransaction = await inboundTransactionPromise ;
278
246
279
247
const traceId = inboundTransaction ?. contexts ?. trace ?. trace_id ;
280
- const spanId = inboundTransaction ?. spans ?. find (
281
- ( span ) => span . op === 'http.client' ,
282
- ) ?. span_id ;
248
+ const spanId = inboundTransaction ?. spans ?. find ( span => span . op === 'http.client' ) ?. span_id ;
283
249
284
250
expect ( traceId ) . toEqual ( expect . any ( String ) ) ;
285
251
expect ( spanId ) . toEqual ( expect . any ( String ) ) ;
@@ -302,30 +268,20 @@ test('Propagates trace for outgoing external http requests', async ({
302
268
) ;
303
269
} ) ;
304
270
305
- test ( 'Does not propagate outgoing http requests not covered by tracePropagationTargets' , async ( {
306
- baseURL,
307
- } ) => {
308
- const inboundTransactionPromise = waitForTransaction (
309
- 'node-nestjs-app' ,
310
- ( transactionEvent ) => {
311
- return (
312
- transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
313
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
314
- `/test-outgoing-http-external-disallowed`
315
- ) ;
316
- } ,
317
- ) ;
271
+ test ( 'Does not propagate outgoing http requests not covered by tracePropagationTargets' , async ( { baseURL } ) => {
272
+ const inboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
273
+ return (
274
+ transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
275
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-outgoing-http-external-disallowed`
276
+ ) ;
277
+ } ) ;
318
278
319
- const { data } = await axios . get (
320
- `${ baseURL } /test-outgoing-http-external-disallowed` ,
321
- ) ;
279
+ const { data } = await axios . get ( `${ baseURL } /test-outgoing-http-external-disallowed` ) ;
322
280
323
281
const inboundTransaction = await inboundTransactionPromise ;
324
282
325
283
const traceId = inboundTransaction ?. contexts ?. trace ?. trace_id ;
326
- const spanId = inboundTransaction ?. spans ?. find (
327
- ( span ) => span . op === 'http.client' ,
328
- ) ?. span_id ;
284
+ const spanId = inboundTransaction ?. spans ?. find ( span => span . op === 'http.client' ) ?. span_id ;
329
285
330
286
expect ( traceId ) . toEqual ( expect . any ( String ) ) ;
331
287
expect ( spanId ) . toEqual ( expect . any ( String ) ) ;
@@ -335,30 +291,20 @@ test('Does not propagate outgoing http requests not covered by tracePropagationT
335
291
expect ( data . headers ?. baggage ) . toBeUndefined ( ) ;
336
292
} ) ;
337
293
338
- test ( 'Propagates trace for outgoing external fetch requests' , async ( {
339
- baseURL,
340
- } ) => {
341
- const inboundTransactionPromise = waitForTransaction (
342
- 'node-nestjs-app' ,
343
- ( transactionEvent ) => {
344
- return (
345
- transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
346
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
347
- `/test-outgoing-fetch-external-allowed`
348
- ) ;
349
- } ,
350
- ) ;
294
+ test ( 'Propagates trace for outgoing external fetch requests' , async ( { baseURL } ) => {
295
+ const inboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
296
+ return (
297
+ transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
298
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-outgoing-fetch-external-allowed`
299
+ ) ;
300
+ } ) ;
351
301
352
- const { data } = await axios . get (
353
- `${ baseURL } /test-outgoing-fetch-external-allowed` ,
354
- ) ;
302
+ const { data } = await axios . get ( `${ baseURL } /test-outgoing-fetch-external-allowed` ) ;
355
303
356
304
const inboundTransaction = await inboundTransactionPromise ;
357
305
358
306
const traceId = inboundTransaction ?. contexts ?. trace ?. trace_id ;
359
- const spanId = inboundTransaction ?. spans ?. find (
360
- ( span ) => span . op === 'http.client' ,
361
- ) ?. span_id ;
307
+ const spanId = inboundTransaction ?. spans ?. find ( span => span . op === 'http.client' ) ?. span_id ;
362
308
363
309
expect ( traceId ) . toEqual ( expect . any ( String ) ) ;
364
310
expect ( spanId ) . toEqual ( expect . any ( String ) ) ;
@@ -381,30 +327,20 @@ test('Propagates trace for outgoing external fetch requests', async ({
381
327
) ;
382
328
} ) ;
383
329
384
- test ( 'Does not propagate outgoing fetch requests not covered by tracePropagationTargets' , async ( {
385
- baseURL,
386
- } ) => {
387
- const inboundTransactionPromise = waitForTransaction (
388
- 'node-nestjs-app' ,
389
- ( transactionEvent ) => {
390
- return (
391
- transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
392
- transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] ===
393
- `/test-outgoing-fetch-external-disallowed`
394
- ) ;
395
- } ,
396
- ) ;
330
+ test ( 'Does not propagate outgoing fetch requests not covered by tracePropagationTargets' , async ( { baseURL } ) => {
331
+ const inboundTransactionPromise = waitForTransaction ( 'node-nestjs-app' , transactionEvent => {
332
+ return (
333
+ transactionEvent ?. contexts ?. trace ?. op === 'http.server' &&
334
+ transactionEvent . contexts ?. trace ?. data ?. [ 'http.target' ] === `/test-outgoing-fetch-external-disallowed`
335
+ ) ;
336
+ } ) ;
397
337
398
- const { data } = await axios . get (
399
- `${ baseURL } /test-outgoing-fetch-external-disallowed` ,
400
- ) ;
338
+ const { data } = await axios . get ( `${ baseURL } /test-outgoing-fetch-external-disallowed` ) ;
401
339
402
340
const inboundTransaction = await inboundTransactionPromise ;
403
341
404
342
const traceId = inboundTransaction ?. contexts ?. trace ?. trace_id ;
405
- const spanId = inboundTransaction ?. spans ?. find (
406
- ( span ) => span . op === 'http.client' ,
407
- ) ?. span_id ;
343
+ const spanId = inboundTransaction ?. spans ?. find ( span => span . op === 'http.client' ) ?. span_id ;
408
344
409
345
expect ( traceId ) . toEqual ( expect . any ( String ) ) ;
410
346
expect ( spanId ) . toEqual ( expect . any ( String ) ) ;
0 commit comments