File tree Expand file tree Collapse file tree
dev-packages/e2e-tests/test-applications/nitro-3/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { expect , test } from '@playwright/test' ;
2- import { collectStreamedSpans } from '@sentry-internal/test-utils' ;
2+ import { collectStreamedSpansUntilSegment } from '@sentry-internal/test-utils' ;
33
44test . describe ( 'Cache Instrumentation' , ( ) => {
55 const SEMANTIC_ATTRIBUTE_CACHE_KEY = 'cache.key' ;
66 const SEMANTIC_ATTRIBUTE_CACHE_HIT = 'cache.hit' ;
77
8- // Streamed spans arrive across several envelopes (a child can flush before its segment),
9- // so accumulate until the segment span has arrived and filter by its trace.
108 async function collectCacheSpans ( ) {
11- const spans = await collectStreamedSpans ( 'nitro-3' , spans =>
12- spans . some ( span => span . is_segment && span . attributes [ 'url.path' ] ?. value === '/api/test-cache' ) ,
9+ const spans = await collectStreamedSpansUntilSegment (
10+ 'nitro-3' ,
11+ span => span . attributes [ 'url.path' ] ?. value === '/api/test-cache' ,
1312 ) ;
14- const segmentSpan = spans . find ( span => span . is_segment && span . attributes [ 'url.path' ] ?. value === '/api/test-cache' ) ;
1513
16- return spans . filter (
17- span => span . trace_id === segmentSpan ?. trace_id && span . attributes [ 'sentry.origin' ] ?. value === 'auto.cache.nitro' ,
18- ) ;
14+ return spans . filter ( span => span . attributes [ 'sentry.origin' ] ?. value === 'auto.cache.nitro' ) ;
1915 }
2016
2117 test ( 'instruments cachedFunction and cachedHandler calls and creates spans with correct attributes' , async ( {
Original file line number Diff line number Diff line change 11import { expect , test } from '@playwright/test' ;
2- import { collectStreamedSpans , getSpanOp } from '@sentry-internal/test-utils' ;
2+ import { collectStreamedSpansUntilSegment , getSpanOp } from '@sentry-internal/test-utils' ;
33
4- // Streamed spans arrive across several envelopes (a child can flush before its segment),
5- // so accumulate until the segment span has arrived and filter by its trace.
6- async function collectNestingSpans ( ) {
7- const spans = await collectStreamedSpans ( 'nitro-3' , spans =>
8- spans . some ( span => span . is_segment && span . name === 'GET /api/test-nesting' ) ,
9- ) ;
10- const segmentSpan = spans . find ( span => span . is_segment && span . name === 'GET /api/test-nesting' ) ;
11- return spans . filter ( span => span . trace_id === segmentSpan ?. trace_id ) ;
4+ function collectNestingSpans ( ) {
5+ return collectStreamedSpansUntilSegment ( 'nitro-3' , 'GET /api/test-nesting' ) ;
126}
137
148test ( 'Span nesting: all spans share the same trace_id' , async ( { request } ) => {
15- const spansPromise = collectStreamedSpans ( 'nitro-3' , spans =>
16- spans . some ( span => span . is_segment && span . name === 'GET /api/test-nesting' ) ,
17- ) ;
9+ const spansPromise = collectNestingSpans ( ) ;
1810
1911 await request . get ( '/api/test-nesting' ) ;
2012
Original file line number Diff line number Diff line change 11import { expect , test } from '@playwright/test' ;
2- import { collectStreamedSpans } from '@sentry-internal/test-utils' ;
2+ import { collectStreamedSpansUntilSegment } from '@sentry-internal/test-utils' ;
33
4- // Streamed spans arrive across several envelopes (a child can flush before its segment),
5- // so accumulate until the segment span has arrived and filter by its trace.
64async function collectStorageSpans ( route : string ) {
7- const spans = await collectStreamedSpans ( 'nitro-3' , spans =>
8- spans . some ( span => span . is_segment && span . attributes [ 'url.path' ] ?. value === route ) ,
9- ) ;
10- const segmentSpan = spans . find ( span => span . is_segment && span . attributes [ 'url.path' ] ?. value === route ) ;
5+ const spans = await collectStreamedSpansUntilSegment ( 'nitro-3' , span => span . attributes [ 'url.path' ] ?. value === route ) ;
116
12- return spans . filter (
13- span => span . trace_id === segmentSpan ?. trace_id && span . attributes [ 'sentry.origin' ] ?. value === 'auto.cache.nitro' ,
14- ) ;
7+ return spans . filter ( span => span . attributes [ 'sentry.origin' ] ?. value === 'auto.cache.nitro' ) ;
158}
169
1710test . describe ( 'Storage Instrumentation - Aliases' , ( ) => {
Original file line number Diff line number Diff line change 11import { expect , test } from '@playwright/test' ;
2- import { collectStreamedSpans } from '@sentry-internal/test-utils' ;
2+ import { collectStreamedSpansUntilSegment } from '@sentry-internal/test-utils' ;
33
4- // Streamed spans arrive across several envelopes (a child can flush before its segment),
5- // so accumulate until the segment span has arrived and filter by its trace.
64async function collectStorageSpans ( route : string ) {
7- const spans = await collectStreamedSpans ( 'nitro-3' , spans =>
8- spans . some ( span => span . is_segment && span . attributes [ 'url.path' ] ?. value === route ) ,
9- ) ;
10- const segmentSpan = spans . find ( span => span . is_segment && span . attributes [ 'url.path' ] ?. value === route ) ;
11-
12- return spans . filter (
13- span => span . trace_id === segmentSpan ?. trace_id && span . attributes [ 'sentry.origin' ] ?. value === 'auto.cache.nitro' ,
14- ) ;
5+ const spans = await collectStreamedSpansUntilSegment ( 'nitro-3' , span => span . attributes [ 'url.path' ] ?. value === route ) ;
6+
7+ return spans . filter ( span => span . attributes [ 'sentry.origin' ] ?. value === 'auto.cache.nitro' ) ;
158}
169
1710test . describe ( 'Storage Instrumentation' , ( ) => {
You can’t perform that action at this time.
0 commit comments