@@ -24,18 +24,18 @@ export class IdleTransactionSpanRecorder extends SpanRecorder {
24
24
* @inheritDoc
25
25
*/
26
26
public add ( span : Span ) : void {
27
- // tslint:disable-next-line: no-unbound-method
28
- const oldFinish : Function = span . finish ;
29
27
span . finish = ( endTimestamp ?: number ) => {
30
- oldFinish ( endTimestamp ) ;
28
+ span . endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampWithMs ( ) ;
31
29
if ( this . _popActivity ) {
32
30
this . _popActivity ( span . spanId ) ;
33
31
}
34
32
} ;
35
33
36
34
super . add ( span ) ;
37
- if ( this . _pushActivity && ! span . endTimestamp ) {
38
- this . _pushActivity ( span . spanId ) ;
35
+ if ( span && ! span . endTimestamp ) {
36
+ if ( this . _pushActivity ) {
37
+ this . _pushActivity ( span . spanId ) ;
38
+ }
39
39
}
40
40
}
41
41
}
@@ -71,10 +71,12 @@ export class IdleTransaction extends Transaction {
71
71
if ( hub ) {
72
72
// We set the transaction here on the scope so error events pick up the trace
73
73
// context and attach it to the error.
74
+ logger . log ( 'Setting transaction on scope' ) ;
74
75
hub . configureScope ( scope => scope . setSpan ( this ) ) ;
75
76
}
76
77
77
- // Start heartbeat so that transactions do not run forever.
78
+ // Start heartbeat so that transactions do not run forever.\
79
+ logger . log ( 'Starting heartbeat' ) ;
78
80
this . _pingHeartbeat ( ) ;
79
81
}
80
82
@@ -141,7 +143,9 @@ export class IdleTransaction extends Transaction {
141
143
* Finish the current active idle transaction
142
144
*/
143
145
private _finishIdleTransaction ( endTimestamp : number ) : void {
144
- if ( this . spanRecorder ) {
146
+ if ( this . spanRecorder && ! this . _finished ) {
147
+ logger . log ( '[Tracing] finishing IdleTransaction' , new Date ( endTimestamp * 1000 ) . toISOString ( ) ) ;
148
+
145
149
if ( this . _finishCallback ) {
146
150
this . _finishCallback ( this ) ;
147
151
}
@@ -183,6 +187,8 @@ export class IdleTransaction extends Transaction {
183
187
* @param spanId The span id that represents the activity
184
188
*/
185
189
private _pushActivity ( spanId : string ) : void {
190
+ logger . log ( `[Tracing] pushActivity: ${ spanId } ` ) ;
191
+ logger . log ( '[Tracing] activies count' , Object . keys ( this . activities ) . length ) ;
186
192
this . activities [ spanId ] = true ;
187
193
}
188
194
@@ -192,6 +198,7 @@ export class IdleTransaction extends Transaction {
192
198
*/
193
199
private _popActivity ( spanId : string ) : void {
194
200
if ( this . activities [ spanId ] ) {
201
+ logger . log ( `[Tracing] popActivity ${ spanId } ` ) ;
195
202
// tslint:disable-next-line: no-dynamic-delete
196
203
delete this . activities [ spanId ] ;
197
204
}
0 commit comments