@@ -7,37 +7,27 @@ import { waitForTransaction } from '../event-proxy-server';
77test ( 'Propagates trace for outgoing http requests' ,  async  ( {  baseURL } )  =>  { 
88  const  id  =  crypto . randomUUID ( ) ; 
99
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+   } ) ; 
2016
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+   } ) ; 
3123
3224  const  {  data }  =  await  axios . get ( `${ baseURL } ${ id }  ) ; 
3325
3426  const  inboundTransaction  =  await  inboundTransactionPromise ; 
3527  const  outboundTransaction  =  await  outboundTransactionPromise ; 
3628
3729  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 ; 
4131
4232  expect ( outgoingHttpSpan ) . toBeDefined ( ) ; 
4333
@@ -49,9 +39,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
4939  const  inboundHeaderSentryTrace  =  data . headers ?. [ 'sentry-trace' ] ; 
5040  const  inboundHeaderBaggage  =  data . headers ?. [ 'baggage' ] ; 
5141
52-   expect ( inboundHeaderSentryTrace ) . toEqual ( 
53-     `${ traceId } ${ outgoingHttpSpanId }  , 
54-   ) ; 
42+   expect ( inboundHeaderSentryTrace ) . toEqual ( `${ traceId } ${ outgoingHttpSpanId }  ) ; 
5543  expect ( inboundHeaderBaggage ) . toBeDefined ( ) ; 
5644
5745  const  baggage  =  ( inboundHeaderBaggage  ||  '' ) . split ( ',' ) ; 
@@ -133,37 +121,27 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
133121test ( 'Propagates trace for outgoing fetch requests' ,  async  ( {  baseURL } )  =>  { 
134122  const  id  =  crypto . randomUUID ( ) ; 
135123
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+   } ) ; 
146130
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+   } ) ; 
157137
158138  const  {  data }  =  await  axios . get ( `${ baseURL } ${ id }  ) ; 
159139
160140  const  inboundTransaction  =  await  inboundTransactionPromise ; 
161141  const  outboundTransaction  =  await  outboundTransactionPromise ; 
162142
163143  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 ; 
167145
168146  expect ( outgoingHttpSpan ) . toBeDefined ( ) ; 
169147
@@ -175,9 +153,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
175153  const  inboundHeaderSentryTrace  =  data . headers ?. [ 'sentry-trace' ] ; 
176154  const  inboundHeaderBaggage  =  data . headers ?. [ 'baggage' ] ; 
177155
178-   expect ( inboundHeaderSentryTrace ) . toEqual ( 
179-     `${ traceId } ${ outgoingHttpSpanId }  , 
180-   ) ; 
156+   expect ( inboundHeaderSentryTrace ) . toEqual ( `${ traceId } ${ outgoingHttpSpanId }  ) ; 
181157  expect ( inboundHeaderBaggage ) . toBeDefined ( ) ; 
182158
183159  const  baggage  =  ( inboundHeaderBaggage  ||  '' ) . split ( ',' ) ; 
@@ -256,30 +232,20 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
256232  } ) ; 
257233} ) ; 
258234
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+   } ) ; 
272242
273-   const  {  data }  =  await  axios . get ( 
274-     `${ baseURL }  , 
275-   ) ; 
243+   const  {  data }  =  await  axios . get ( `${ baseURL }  ) ; 
276244
277245  const  inboundTransaction  =  await  inboundTransactionPromise ; 
278246
279247  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 ; 
283249
284250  expect ( traceId ) . toEqual ( expect . any ( String ) ) ; 
285251  expect ( spanId ) . toEqual ( expect . any ( String ) ) ; 
@@ -302,30 +268,20 @@ test('Propagates trace for outgoing external http requests', async ({
302268  ) ; 
303269} ) ; 
304270
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+   } ) ; 
318278
319-   const  {  data }  =  await  axios . get ( 
320-     `${ baseURL }  , 
321-   ) ; 
279+   const  {  data }  =  await  axios . get ( `${ baseURL }  ) ; 
322280
323281  const  inboundTransaction  =  await  inboundTransactionPromise ; 
324282
325283  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 ; 
329285
330286  expect ( traceId ) . toEqual ( expect . any ( String ) ) ; 
331287  expect ( spanId ) . toEqual ( expect . any ( String ) ) ; 
@@ -335,30 +291,20 @@ test('Does not propagate outgoing http requests not covered by tracePropagationT
335291  expect ( data . headers ?. baggage ) . toBeUndefined ( ) ; 
336292} ) ; 
337293
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+   } ) ; 
351301
352-   const  {  data }  =  await  axios . get ( 
353-     `${ baseURL }  , 
354-   ) ; 
302+   const  {  data }  =  await  axios . get ( `${ baseURL }  ) ; 
355303
356304  const  inboundTransaction  =  await  inboundTransactionPromise ; 
357305
358306  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 ; 
362308
363309  expect ( traceId ) . toEqual ( expect . any ( String ) ) ; 
364310  expect ( spanId ) . toEqual ( expect . any ( String ) ) ; 
@@ -381,30 +327,20 @@ test('Propagates trace for outgoing external fetch requests', async ({
381327  ) ; 
382328} ) ; 
383329
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+   } ) ; 
397337
398-   const  {  data }  =  await  axios . get ( 
399-     `${ baseURL }  , 
400-   ) ; 
338+   const  {  data }  =  await  axios . get ( `${ baseURL }  ) ; 
401339
402340  const  inboundTransaction  =  await  inboundTransactionPromise ; 
403341
404342  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 ; 
408344
409345  expect ( traceId ) . toEqual ( expect . any ( String ) ) ; 
410346  expect ( spanId ) . toEqual ( expect . any ( String ) ) ; 
0 commit comments