@@ -633,4 +633,63 @@ describe('Integration | Transactions', () => {
633633 ] ) ,
634634 ) ;
635635 } ) ;
636+
637+ it ( 'allows to configure `maxSpanWaitDuration` to capture long running spans' , async ( ) => {
638+ const transactions : TransactionEvent [ ] = [ ] ;
639+ const beforeSendTransaction = jest . fn ( event => {
640+ transactions . push ( event ) ;
641+ return null ;
642+ } ) ;
643+
644+ const now = Date . now ( ) ;
645+ jest . useFakeTimers ( ) ;
646+ jest . setSystemTime ( now ) ;
647+
648+ const logs : unknown [ ] = [ ] ;
649+ jest . spyOn ( logger , 'log' ) . mockImplementation ( msg => logs . push ( msg ) ) ;
650+
651+ mockSdkInit ( {
652+ enableTracing : true ,
653+ beforeSendTransaction,
654+ maxSpanWaitDuration : 100 * 60 ,
655+ } ) ;
656+
657+ Sentry . startSpanManual ( { name : 'test name' } , rootSpan => {
658+ const subSpan = Sentry . startInactiveSpan ( { name : 'inner span 1' } ) ;
659+ subSpan . end ( ) ;
660+
661+ Sentry . startSpanManual ( { name : 'inner span 2' } , innerSpan => {
662+ // Child span ends after 10 min
663+ setTimeout (
664+ ( ) => {
665+ innerSpan . end ( ) ;
666+ } ,
667+ 10 * 60 * 1_000 ,
668+ ) ;
669+ } ) ;
670+
671+ // root span ends after 99 min
672+ setTimeout (
673+ ( ) => {
674+ rootSpan . end ( ) ;
675+ } ,
676+ 99 * 10 * 1_000 ,
677+ ) ;
678+ } ) ;
679+
680+ // Now wait for 100 mins
681+ jest . advanceTimersByTime ( 100 * 60 * 1_000 ) ;
682+
683+ expect ( beforeSendTransaction ) . toHaveBeenCalledTimes ( 1 ) ;
684+ expect ( transactions ) . toHaveLength ( 1 ) ;
685+ const transaction = transactions [ 0 ] ! ;
686+
687+ expect ( transaction . transaction ) . toEqual ( 'test name' ) ;
688+ const spans = transaction . spans || [ ] ;
689+
690+ expect ( spans ) . toHaveLength ( 2 ) ;
691+
692+ expect ( spans [ 0 ] ! . description ) . toEqual ( 'inner span 1' ) ;
693+ expect ( spans [ 1 ] ! . description ) . toEqual ( 'inner span 2' ) ;
694+ } ) ;
636695} ) ;
0 commit comments