@@ -162,9 +162,9 @@ export class Tracing implements Integration {
162
162
163
163
if ( this . _emitOptionsWarning ) {
164
164
logger . warn (
165
- 'Sentry: You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.' ,
165
+ '[Tracing] You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.' ,
166
166
) ;
167
- logger . warn ( `Sentry: We added a reasonable default for you: ${ defaultTracingOrigins } ` ) ;
167
+ logger . warn ( `[Tracing] We added a reasonable default for you: ${ defaultTracingOrigins } ` ) ;
168
168
}
169
169
170
170
if ( ! Tracing . _isEnabled ( ) ) {
@@ -255,6 +255,8 @@ export class Tracing implements Integration {
255
255
// b) A activity wasn't popped correctly and therefore the transaction is stalling
256
256
Tracing . finishIdleTransaction ( ) ;
257
257
258
+ logger . log ( '[Tracing] startIdleTransaction, name:' , name ) ;
259
+
258
260
const _getCurrentHub = Tracing . _getCurrentHub ;
259
261
if ( ! _getCurrentHub ) {
260
262
return undefined ;
@@ -296,6 +298,7 @@ export class Tracing implements Integration {
296
298
* @deprecated
297
299
*/
298
300
public static updateTransactionName ( name : string ) : void {
301
+ logger . log ( '[Tracing] DEPRECATED, use Sentry.configureScope => scope.setTransaction instead' , name ) ;
299
302
const _getCurrentHub = Tracing . _getCurrentHub ;
300
303
if ( _getCurrentHub ) {
301
304
const hub = _getCurrentHub ( ) ;
@@ -313,6 +316,7 @@ export class Tracing implements Integration {
313
316
public static finishIdleTransaction ( ) : void {
314
317
const active = Tracing . _activeTransaction as SpanClass ;
315
318
if ( active ) {
319
+ logger . log ( '[Tracing] finishIdleTransaction' , active . transaction ) ;
316
320
// true = use timestamp of last span
317
321
active . finish ( true ) ;
318
322
}
@@ -324,14 +328,25 @@ export class Tracing implements Integration {
324
328
public static setTransactionStatus ( status : SpanStatus ) : void {
325
329
const active = Tracing . _activeTransaction ;
326
330
if ( active ) {
331
+ logger . log ( '[Tracing] setTransactionStatus' , status ) ;
327
332
active . setStatus ( status ) ;
328
333
}
329
334
}
330
335
331
336
/**
332
337
* Starts tracking for a specifc activity
338
+ *
339
+ * @param name Name of the activity, can be any string (Only used internally to identify the activity)
340
+ * @param spanContext If provided a Span with the SpanContext will be created.
341
+ * @param options _autoPopAfter_ | Time in ms, if provided the activity will be popped automatically after this timeout. This can be helpful in cases where you cannot gurantee your application knows the state and calls `popActivity` for sure.
333
342
*/
334
- public static pushActivity ( name : string , spanContext ?: SpanContext ) : number {
343
+ public static pushActivity (
344
+ name : string ,
345
+ spanContext ?: SpanContext ,
346
+ options ?: {
347
+ autoPopAfter ?: number ;
348
+ } ,
349
+ ) : number {
335
350
if ( ! Tracing . _isEnabled ( ) ) {
336
351
// Tracing is not enabled
337
352
return 0 ;
@@ -355,6 +370,18 @@ export class Tracing implements Integration {
355
370
} ;
356
371
}
357
372
373
+ logger . log ( `[Tracing] pushActivity: ${ name } #${ Tracing . _currentIndex } ` ) ;
374
+ logger . log ( '[Tracing] activies count' , Object . keys ( Tracing . _activities ) . length ) ;
375
+ if ( options && typeof options . autoPopAfter === 'number' ) {
376
+ logger . log ( `[Tracing] auto pop of: ${ name } #${ Tracing . _currentIndex } in ${ options . autoPopAfter } ms` ) ;
377
+ const index = Tracing . _currentIndex ;
378
+ setTimeout ( ( ) => {
379
+ Tracing . popActivity ( index , {
380
+ autoPop : true ,
381
+ status : SpanStatus . DeadlineExceeded ,
382
+ } ) ;
383
+ } , options . autoPopAfter ) ;
384
+ }
358
385
return Tracing . _currentIndex ++ ;
359
386
}
360
387
@@ -368,7 +395,9 @@ export class Tracing implements Integration {
368
395
}
369
396
370
397
const activity = Tracing . _activities [ id ] ;
398
+
371
399
if ( activity ) {
400
+ logger . log ( `[Tracing] popActivity ${ activity . name } #${ id } ` ) ;
372
401
const span = activity . span ;
373
402
if ( span ) {
374
403
if ( spanData ) {
@@ -377,6 +406,9 @@ export class Tracing implements Integration {
377
406
if ( key === 'status_code' ) {
378
407
span . setHttpStatus ( spanData [ key ] as number ) ;
379
408
}
409
+ if ( key === 'status' ) {
410
+ span . setStatus ( spanData [ key ] as SpanStatus ) ;
411
+ }
380
412
} ) ;
381
413
}
382
414
span . finish ( ) ;
@@ -388,8 +420,11 @@ export class Tracing implements Integration {
388
420
const count = Object . keys ( Tracing . _activities ) . length ;
389
421
clearTimeout ( Tracing . _debounce ) ;
390
422
423
+ logger . log ( '[Tracing] activies count' , count ) ;
424
+
391
425
if ( count === 0 ) {
392
426
const timeout = Tracing . options && Tracing . options . idleTimeout ;
427
+ logger . log ( `[Tracing] Flushing Transaction in ${ timeout } ms` ) ;
393
428
Tracing . _debounce = ( setTimeout ( ( ) => {
394
429
Tracing . finishIdleTransaction ( ) ;
395
430
} , timeout ) as any ) as number ;
0 commit comments