@@ -162,9 +162,9 @@ export class Tracing implements Integration {
162162
163163 if ( this . _emitOptionsWarning ) {
164164 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.' ,
166166 ) ;
167- logger . warn ( `Sentry: We added a reasonable default for you: ${ defaultTracingOrigins } ` ) ;
167+ logger . warn ( `[Tracing] We added a reasonable default for you: ${ defaultTracingOrigins } ` ) ;
168168 }
169169
170170 if ( ! Tracing . _isEnabled ( ) ) {
@@ -255,6 +255,8 @@ export class Tracing implements Integration {
255255 // b) A activity wasn't popped correctly and therefore the transaction is stalling
256256 Tracing . finishIdleTransaction ( ) ;
257257
258+ logger . log ( '[Tracing] startIdleTransaction, name:' , name ) ;
259+
258260 const _getCurrentHub = Tracing . _getCurrentHub ;
259261 if ( ! _getCurrentHub ) {
260262 return undefined ;
@@ -296,6 +298,7 @@ export class Tracing implements Integration {
296298 * @deprecated
297299 */
298300 public static updateTransactionName ( name : string ) : void {
301+ logger . log ( '[Tracing] DEPRECATED, use Sentry.configureScope => scope.setTransaction instead' , name ) ;
299302 const _getCurrentHub = Tracing . _getCurrentHub ;
300303 if ( _getCurrentHub ) {
301304 const hub = _getCurrentHub ( ) ;
@@ -313,6 +316,7 @@ export class Tracing implements Integration {
313316 public static finishIdleTransaction ( ) : void {
314317 const active = Tracing . _activeTransaction as SpanClass ;
315318 if ( active ) {
319+ logger . log ( '[Tracing] finishIdleTransaction' , active . transaction ) ;
316320 // true = use timestamp of last span
317321 active . finish ( true ) ;
318322 }
@@ -324,14 +328,25 @@ export class Tracing implements Integration {
324328 public static setTransactionStatus ( status : SpanStatus ) : void {
325329 const active = Tracing . _activeTransaction ;
326330 if ( active ) {
331+ logger . log ( '[Tracing] setTransactionStatus' , status ) ;
327332 active . setStatus ( status ) ;
328333 }
329334 }
330335
331336 /**
332337 * 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.
333342 */
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 {
335350 if ( ! Tracing . _isEnabled ( ) ) {
336351 // Tracing is not enabled
337352 return 0 ;
@@ -355,6 +370,18 @@ export class Tracing implements Integration {
355370 } ;
356371 }
357372
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+ }
358385 return Tracing . _currentIndex ++ ;
359386 }
360387
@@ -368,7 +395,9 @@ export class Tracing implements Integration {
368395 }
369396
370397 const activity = Tracing . _activities [ id ] ;
398+
371399 if ( activity ) {
400+ logger . log ( `[Tracing] popActivity ${ activity . name } #${ id } ` ) ;
372401 const span = activity . span ;
373402 if ( span ) {
374403 if ( spanData ) {
@@ -377,6 +406,9 @@ export class Tracing implements Integration {
377406 if ( key === 'status_code' ) {
378407 span . setHttpStatus ( spanData [ key ] as number ) ;
379408 }
409+ if ( key === 'status' ) {
410+ span . setStatus ( spanData [ key ] as SpanStatus ) ;
411+ }
380412 } ) ;
381413 }
382414 span . finish ( ) ;
@@ -388,8 +420,11 @@ export class Tracing implements Integration {
388420 const count = Object . keys ( Tracing . _activities ) . length ;
389421 clearTimeout ( Tracing . _debounce ) ;
390422
423+ logger . log ( '[Tracing] activies count' , count ) ;
424+
391425 if ( count === 0 ) {
392426 const timeout = Tracing . options && Tracing . options . idleTimeout ;
427+ logger . log ( `[Tracing] Flushing Transaction in ${ timeout } ms` ) ;
393428 Tracing . _debounce = ( setTimeout ( ( ) => {
394429 Tracing . finishIdleTransaction ( ) ;
395430 } , timeout ) as any ) as number ;
0 commit comments