@@ -180,10 +180,10 @@ describe('Span', () => {
180
180
expect ( span . endTimestamp ) . toBeGreaterThan ( 1 ) ;
181
181
} ) ;
182
182
183
- describe ( 'hub.startSpan ' , ( ) => {
183
+ describe ( 'hub.startTransaction ' , ( ) => {
184
184
test ( 'finish a transaction' , ( ) => {
185
185
const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
186
- const transaction = hub . startSpan ( { name : 'test' } ) ;
186
+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
187
187
transaction . finish ( ) ;
188
188
expect ( spy ) . toHaveBeenCalled ( ) ;
189
189
expect ( spy . mock . calls [ 0 ] [ 0 ] . spans ) . toHaveLength ( 0 ) ;
@@ -194,7 +194,7 @@ describe('Span', () => {
194
194
195
195
test ( 'finish a transaction + child span' , ( ) => {
196
196
const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
197
- const transaction = hub . startSpan ( { name : 'test' } ) ;
197
+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
198
198
const childSpan = transaction . startChild ( ) ;
199
199
childSpan . finish ( ) ;
200
200
transaction . finish ( ) ;
@@ -205,16 +205,15 @@ describe('Span', () => {
205
205
206
206
test ( "finish a child span shouldn't trigger captureEvent" , ( ) => {
207
207
const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
208
- const transaction = hub . startSpan ( { name : 'test' } ) ;
208
+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
209
209
const childSpan = transaction . startChild ( ) ;
210
210
childSpan . finish ( ) ;
211
211
expect ( spy ) . not . toHaveBeenCalled ( ) ;
212
212
} ) ;
213
213
214
214
test ( "finish a span with another one on the scope shouldn't override contexts.trace" , ( ) => {
215
215
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' } ) ;
218
217
const childSpanOne = transaction . startChild ( ) ;
219
218
childSpanOne . finish ( ) ;
220
219
@@ -239,7 +238,7 @@ describe('Span', () => {
239
238
} ) ,
240
239
) ;
241
240
const spy = jest . spyOn ( _hub as any , 'captureEvent' ) as any ;
242
- const transaction = _hub . startSpan ( { name : 'test' } ) ;
241
+ const transaction = _hub . startTransaction ( { name : 'test' } ) ;
243
242
for ( let i = 0 ; i < 10 ; i ++ ) {
244
243
const child = transaction . startChild ( ) ;
245
244
child . finish ( ) ;
@@ -255,7 +254,7 @@ describe('Span', () => {
255
254
} ) ,
256
255
) ;
257
256
const spy = jest . spyOn ( _hub as any , 'captureEvent' ) as any ;
258
- const transaction = _hub . startSpan ( { name : 'test' } ) ;
257
+ const transaction = _hub . startTransaction ( { name : 'test' } ) ;
259
258
for ( let i = 0 ; i < 10 ; i ++ ) {
260
259
const child = transaction . startChild ( ) ;
261
260
child . finish ( ) ;
@@ -274,7 +273,7 @@ describe('Span', () => {
274
273
) ;
275
274
const spy = jest . spyOn ( _hub as any , 'captureEvent' ) as any ;
276
275
277
- const transaction = _hub . startSpan ( { name : 'test' } ) ;
276
+ const transaction = _hub . startTransaction ( { name : 'test' } ) ;
278
277
const childSpanOne = transaction . startChild ( { op : '1' } ) ;
279
278
childSpanOne . finish ( ) ;
280
279
@@ -297,7 +296,7 @@ describe('Span', () => {
297
296
test ( 'tree structure of spans should be correct when mixing it with span on scope' , ( ) => {
298
297
const spy = jest . spyOn ( hub as any , 'captureEvent' ) as any ;
299
298
300
- const transaction = hub . startSpan ( { name : 'test' } ) ;
299
+ const transaction = hub . startTransaction ( { name : 'test' } ) ;
301
300
const childSpanOne = transaction . startChild ( ) ;
302
301
303
302
const childSpanTwo = childSpanOne . startChild ( ) ;
@@ -321,6 +320,50 @@ describe('Span', () => {
321
320
expect ( spanTwo . toJSON ( ) . parent_span_id ) . toEqual ( transaction . toJSON ( ) . span_id ) ;
322
321
} ) ;
323
322
} ) ;
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
+ } ) ;
324
367
} ) ;
325
368
326
369
describe ( 'getTraceContext' , ( ) => {
0 commit comments