@@ -23,7 +23,7 @@ import {
2323 withActiveSpan ,
2424} from '../../../src/tracing' ;
2525import { SentryNonRecordingSpan } from '../../../src/tracing/sentryNonRecordingSpan' ;
26- import { getActiveSpan , getSpanDescendants } from '../../../src/utils/spanUtils' ;
26+ import { getActiveSpan , getRootSpan , getSpanDescendants } from '../../../src/utils/spanUtils' ;
2727import { TestClient , getDefaultTestClientOptions } from '../../mocks/client' ;
2828
2929beforeAll ( ( ) => {
@@ -84,8 +84,8 @@ describe('startSpan', () => {
8484
8585 it ( 'creates a transaction' , async ( ) => {
8686 let _span : Span | undefined = undefined ;
87- client . on ( 'finishTransaction ' , transaction => {
88- _span = transaction ;
87+ client . on ( 'spanEnd ' , span => {
88+ _span = span ;
8989 } ) ;
9090 try {
9191 await startSpan ( { name : 'GET users/[id]' } , ( ) => {
@@ -102,8 +102,8 @@ describe('startSpan', () => {
102102
103103 it ( 'allows traceparent information to be overriden' , async ( ) => {
104104 let _span : Span | undefined = undefined ;
105- client . on ( 'finishTransaction ' , transaction => {
106- _span = transaction ;
105+ client . on ( 'spanEnd ' , span => {
106+ _span = span ;
107107 } ) ;
108108 try {
109109 await startSpan (
@@ -129,8 +129,8 @@ describe('startSpan', () => {
129129
130130 it ( 'allows for transaction to be mutated' , async ( ) => {
131131 let _span : Span | undefined = undefined ;
132- client . on ( 'finishTransaction ' , transaction => {
133- _span = transaction ;
132+ client . on ( 'spanEnd ' , span => {
133+ _span = span ;
134134 } ) ;
135135 try {
136136 await startSpan ( { name : 'GET users/[id]' } , span => {
@@ -146,8 +146,10 @@ describe('startSpan', () => {
146146
147147 it ( 'creates a span with correct description' , async ( ) => {
148148 let _span : Span | undefined = undefined ;
149- client . on ( 'finishTransaction' , transaction => {
150- _span = transaction ;
149+ client . on ( 'spanEnd' , span => {
150+ if ( span === getRootSpan ( span ) ) {
151+ _span = span ;
152+ }
151153 } ) ;
152154 try {
153155 await startSpan ( { name : 'GET users/[id]' , parentSampled : true } , ( ) => {
@@ -170,8 +172,10 @@ describe('startSpan', () => {
170172
171173 it ( 'allows for span to be mutated' , async ( ) => {
172174 let _span : Span | undefined = undefined ;
173- client . on ( 'finishTransaction' , transaction => {
174- _span = transaction ;
175+ client . on ( 'spanEnd' , span => {
176+ if ( span === getRootSpan ( span ) ) {
177+ _span = span ;
178+ }
175179 } ) ;
176180 try {
177181 await startSpan ( { name : 'GET users/[id]' , parentSampled : true } , ( ) => {
@@ -200,8 +204,8 @@ describe('startSpan', () => {
200204 { origin : 'manual' , attributes : { 'sentry.origin' : 'auto.http.browser' } } ,
201205 ] ) ( 'correctly sets the span origin' , async ( ) => {
202206 let _span : Span | undefined = undefined ;
203- client . on ( 'finishTransaction ' , transaction => {
204- _span = transaction ;
207+ client . on ( 'spanEnd ' , span => {
208+ _span = span ;
205209 } ) ;
206210 try {
207211 await startSpan ( { name : 'GET users/[id]' , origin : 'auto.http.browser' } , ( ) => {
0 commit comments