@@ -180,10 +180,10 @@ describe('Span', () => {
180180 expect ( span . endTimestamp ) . toBeGreaterThan ( 1 ) ;
181181 } ) ;
182182
183- describe ( 'hub.startSpan ' , ( ) => {
183+ describe ( 'hub.startTransaction ' , ( ) => {
184184 test ( 'finish a transaction' , ( ) => {
185185 const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
186- const transaction = hub . startSpan ( { name : 'test' } ) ;
186+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
187187 transaction . finish ( ) ;
188188 expect ( spy ) . toHaveBeenCalled ( ) ;
189189 expect ( spy . mock . calls [ 0 ] [ 0 ] . spans ) . toHaveLength ( 0 ) ;
@@ -194,7 +194,7 @@ describe('Span', () => {
194194
195195 test ( 'finish a transaction + child span' , ( ) => {
196196 const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
197- const transaction = hub . startSpan ( { name : 'test' } ) ;
197+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
198198 const childSpan = transaction . startChild ( ) ;
199199 childSpan . finish ( ) ;
200200 transaction . finish ( ) ;
@@ -205,16 +205,15 @@ describe('Span', () => {
205205
206206 test ( "finish a child span shouldn't trigger captureEvent" , ( ) => {
207207 const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
208- const transaction = hub . startSpan ( { name : 'test' } ) ;
208+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
209209 const childSpan = transaction . startChild ( ) ;
210210 childSpan . finish ( ) ;
211211 expect ( spy ) . not . toHaveBeenCalled ( ) ;
212212 } ) ;
213213
214214 test ( "finish a span with another one on the scope shouldn't override contexts.trace" , ( ) => {
215215 const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
216-
217- const transaction = hub . startSpan ( { name : 'test' } ) ;
216+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
218217 const childSpanOne = transaction . startChild ( ) ;
219218 childSpanOne . finish ( ) ;
220219
@@ -239,7 +238,7 @@ describe('Span', () => {
239238 } ) ,
240239 ) ;
241240 const spy = jest . spyOn ( _hub as any , 'captureEvent' ) as any ;
242- const transaction = _hub . startSpan ( { name : 'test' } ) ;
241+ const transaction = _hub . startTransaction ( { name : 'test' } ) ;
243242 for ( let i = 0 ; i < 10 ; i ++ ) {
244243 const child = transaction . startChild ( ) ;
245244 child . finish ( ) ;
@@ -255,7 +254,7 @@ describe('Span', () => {
255254 } ) ,
256255 ) ;
257256 const spy = jest . spyOn ( _hub as any , 'captureEvent' ) as any ;
258- const transaction = _hub . startSpan ( { name : 'test' } ) ;
257+ const transaction = _hub . startTransaction ( { name : 'test' } ) ;
259258 for ( let i = 0 ; i < 10 ; i ++ ) {
260259 const child = transaction . startChild ( ) ;
261260 child . finish ( ) ;
@@ -274,7 +273,7 @@ describe('Span', () => {
274273 ) ;
275274 const spy = jest . spyOn ( _hub as any , 'captureEvent' ) as any ;
276275
277- const transaction = _hub . startSpan ( { name : 'test' } ) ;
276+ const transaction = _hub . startTransaction ( { name : 'test' } ) ;
278277 const childSpanOne = transaction . startChild ( { op : '1' } ) ;
279278 childSpanOne . finish ( ) ;
280279
@@ -297,7 +296,7 @@ describe('Span', () => {
297296 test ( 'tree structure of spans should be correct when mixing it with span on scope' , ( ) => {
298297 const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
299298
300- const transaction = hub . startSpan ( { name : 'test' } ) ;
299+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
301300 const childSpanOne = transaction . startChild ( ) ;
302301
303302 const childSpanTwo = childSpanOne . startChild ( ) ;
@@ -321,6 +320,50 @@ describe('Span', () => {
321320 expect ( spanTwo . toJSON ( ) . parent_span_id ) . toEqual ( transaction . toJSON ( ) . span_id ) ;
322321 } ) ;
323322 } ) ;
323+
324+ describe ( 'hub.startSpan' , ( ) => {
325+ test ( 'finish a transaction' , ( ) => {
326+ const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
327+ // @ts -ignore
328+ const transaction = hub . startSpan ( { name : 'test' } ) ;
329+ transaction . finish ( ) ;
330+ expect ( spy ) . toHaveBeenCalled ( ) ;
331+ expect ( spy . mock . calls [ 0 ] [ 0 ] . spans ) . toHaveLength ( 0 ) ;
332+ expect ( spy . mock . calls [ 0 ] [ 0 ] . timestamp ) . toBeTruthy ( ) ;
333+ expect ( spy . mock . calls [ 0 ] [ 0 ] . start_timestamp ) . toBeTruthy ( ) ;
334+ expect ( spy . mock . calls [ 0 ] [ 0 ] . contexts . trace ) . toEqual ( transaction . getTraceContext ( ) ) ;
335+ } ) ;
336+
337+ test ( 'finish a transaction (deprecated way)' , ( ) => {
338+ const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
339+ // @ts -ignore
340+ const transaction = hub . startSpan ( { transaction : 'test' } ) ;
341+ transaction . finish ( ) ;
342+ expect ( spy ) . toHaveBeenCalled ( ) ;
343+ expect ( spy . mock . calls [ 0 ] [ 0 ] . spans ) . toHaveLength ( 0 ) ;
344+ expect ( spy . mock . calls [ 0 ] [ 0 ] . timestamp ) . toBeTruthy ( ) ;
345+ expect ( spy . mock . calls [ 0 ] [ 0 ] . start_timestamp ) . toBeTruthy ( ) ;
346+ expect ( spy . mock . calls [ 0 ] [ 0 ] . contexts . trace ) . toEqual ( transaction . getTraceContext ( ) ) ;
347+ } ) ;
348+
349+ test ( 'startSpan with Span on the Scope should be a child' , ( ) => {
350+ const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
351+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
352+ const child1 = transaction . startChild ( ) ;
353+ hub . configureScope ( scope => {
354+ scope . setSpan ( child1 ) ;
355+ } ) ;
356+
357+ const child2 = hub . startSpan ( { } ) ;
358+ child1 . finish ( ) ;
359+ child2 . finish ( ) ;
360+ transaction . finish ( ) ;
361+
362+ expect ( spy ) . toHaveBeenCalled ( ) ;
363+ expect ( spy . mock . calls [ 0 ] [ 0 ] . spans ) . toHaveLength ( 2 ) ;
364+ expect ( child2 . parentSpanId ) . toEqual ( child1 . spanId ) ;
365+ } ) ;
366+ } ) ;
324367 } ) ;
325368
326369 describe ( 'getTraceContext' , ( ) => {
0 commit comments