@@ -12,6 +12,10 @@ test('propagates trace context from server-timing header to client pageload', as
1212 return transactionEvent . contexts ?. trace ?. op === 'pageload' && transactionEvent . tags ?. [ 'sentry_test' ] === testTag ;
1313 } ) ;
1414
15+ const httpServerTransactionPromise = waitForTransaction ( 'remix-server-timing' , transactionEvent => {
16+ return transactionEvent . contexts ?. trace ?. op === 'http.server' ;
17+ } ) ;
18+
1519 await page . goto ( `/?tag=${ testTag } ` ) ;
1620
1721 const response = await responsePromise ;
@@ -30,25 +34,46 @@ test('propagates trace context from server-timing header to client pageload', as
3034 expect ( headerSampled ) . toBe ( '1' ) ;
3135
3236 const pageloadTransaction = await pageLoadTransactionPromise ;
37+ const httpServerTransaction = await httpServerTransactionPromise ;
3338
3439 expect ( pageloadTransaction ) . toBeDefined ( ) ;
3540 expect ( pageloadTransaction . transaction ) . toBe ( '/' ) ;
3641
42+ expect ( httpServerTransaction . transaction ) . toMatch ( / ^ G E T h t t p : \/ \/ l o c a l h o s t : \d + \/ $ / ) ;
43+
3744 expect ( pageloadTransaction . contexts ?. trace ?. trace_id ) . toEqual ( headerTraceId ) ;
3845 expect ( pageloadTransaction . contexts ?. trace ?. parent_span_id ) . toEqual ( headerSpanId ) ;
46+
47+ expect ( httpServerTransaction . contexts ?. trace ?. trace_id ) . toEqual ( headerTraceId ) ;
48+ expect ( httpServerTransaction . contexts ?. trace ?. span_id ) . toEqual ( headerSpanId ) ;
3949} ) ;
4050
4151test ( 'includes server-timing header on redirect responses' , async ( { page } ) => {
4252 const redirectResponsePromise = page . waitForResponse ( response => response . url ( ) . includes ( '/redirect-test' ) ) ;
53+ const redirectedPageloadResponsePromise = page . waitForResponse ( response =>
54+ response . url ( ) . includes ( '/user/redirected' ) ,
55+ ) ;
56+
57+ const pageLoadTransactionPromise = waitForTransaction ( 'remix-server-timing' , transactionEvent => {
58+ return transactionEvent . contexts ?. trace ?. op === 'pageload' ;
59+ } ) ;
4360
4461 await page . goto ( '/redirect-test' ) ;
4562
4663 const redirectResponse = await redirectResponsePromise ;
47- const serverTimingHeader = redirectResponse . headers ( ) [ 'server-timing' ] ;
64+ const redirectServerTimingHeader = redirectResponse . headers ( ) [ 'server-timing' ] ;
4865
49- expect ( serverTimingHeader ) . toBeDefined ( ) ;
50- expect ( serverTimingHeader ) . toContain ( 'sentry-trace' ) ;
66+ expect ( redirectServerTimingHeader ) . toBeDefined ( ) ;
67+ expect ( redirectServerTimingHeader ) . toContain ( 'sentry-trace' ) ;
68+ expect ( redirectServerTimingHeader ) . toContain ( 'baggage' ) ;
5169
70+ const redirectSentryTraceMatch = redirectServerTimingHeader ?. match ( / s e n t r y - t r a c e ; d e s c = " ( [ ^ " ] + ) " / ) ;
71+ expect ( redirectSentryTraceMatch ) . toBeTruthy ( ) ;
72+ expect ( redirectSentryTraceMatch ! [ 1 ] ) . toMatch ( / [ a - f 0 - 9 ] { 32 } - [ a - f 0 - 9 ] { 16 } - 1 / ) ;
73+
74+ const redirectedPageloadResponse = await redirectedPageloadResponsePromise ;
75+
76+ const serverTimingHeader = redirectedPageloadResponse . headers ( ) [ 'server-timing' ] ;
5277 const sentryTraceMatch = serverTimingHeader ?. match ( / s e n t r y - t r a c e ; d e s c = " ( [ ^ " ] + ) " / ) ;
5378 expect ( sentryTraceMatch ) . toBeTruthy ( ) ;
5479 const [ traceId , spanId ] = sentryTraceMatch ! [ 1 ] . split ( '-' ) ;
@@ -57,6 +82,11 @@ test('includes server-timing header on redirect responses', async ({ page }) =>
5782
5883 await page . waitForURL ( / \/ u s e r \/ r e d i r e c t e d / ) ;
5984 await expect ( page . locator ( 'h1' ) ) . toContainText ( 'User redirected' ) ;
85+
86+ const pageLoadTransaction = await pageLoadTransactionPromise ;
87+ expect ( pageLoadTransaction . transaction ) . toBe ( '/user/:id' ) ;
88+ expect ( pageLoadTransaction . contexts ?. trace ?. trace_id ) . toEqual ( traceId ) ;
89+ expect ( pageLoadTransaction . contexts ?. trace ?. parent_span_id ) . toEqual ( spanId ) ;
6090} ) ;
6191
6292test ( 'excludes server-timing header from client-side navigation data fetches' , async ( { page } ) => {
0 commit comments