@@ -172,7 +172,7 @@ export class TraceStateMachine<
172
172
VariantsT
173
173
> ,
174
174
) {
175
- this . context = context
175
+ this . # context = context
176
176
this . remainingRequiredSpanIndexes = new Set (
177
177
context . definition . requiredSpans . map ( ( _ , i ) => i ) ,
178
178
)
@@ -181,13 +181,13 @@ export class TraceStateMachine<
181
181
182
182
readonly remainingRequiredSpanIndexes : Set < number >
183
183
184
- readonly context : StateMachineContext <
184
+ readonly # context: StateMachineContext <
185
185
SelectedRelationNameT ,
186
186
RelationSchemasT ,
187
187
VariantsT
188
188
>
189
189
get sideEffectFns ( ) {
190
- return this . context . sideEffectFns
190
+ return this . # context. sideEffectFns
191
191
}
192
192
currentState : TraceStates = INITIAL_STATE
193
193
/** the span that ended at the furthest point in time */
@@ -282,8 +282,8 @@ export class TraceStateMachine<
282
282
draft : {
283
283
onEnterState : ( ) => {
284
284
this . setGlobalDeadline (
285
- this . context . input . startTime . epoch +
286
- this . context . definition . variants [ this . context . input . variant ] !
285
+ this . # context. input . startTime . epoch +
286
+ this . # context. definition . variants [ this . # context. input . variant ] !
287
287
. timeout ,
288
288
)
289
289
} ,
@@ -312,10 +312,10 @@ export class TraceStateMachine<
312
312
313
313
// if the entry matches any of the interruptOnSpans criteria,
314
314
// transition to complete state with the 'matched-on-interrupt' interruptionReason
315
- if ( this . context . definition . interruptOnSpans ) {
316
- for ( const doesSpanMatch of this . context . definition
315
+ if ( this . # context. definition . interruptOnSpans ) {
316
+ for ( const doesSpanMatch of this . # context. definition
317
317
. interruptOnSpans ) {
318
- if ( doesSpanMatch ( spanAndAnnotation , this . context ) ) {
318
+ if ( doesSpanMatch ( spanAndAnnotation , this . # context) ) {
319
319
return {
320
320
transitionToState : 'complete' ,
321
321
interruptionReason : doesSpanMatch . requiredSpan
@@ -377,10 +377,10 @@ export class TraceStateMachine<
377
377
}
378
378
379
379
// does span satisfy any of the "interruptOnSpans" definitions
380
- if ( this . context . definition . interruptOnSpans ) {
381
- for ( const doesSpanMatch of this . context . definition
380
+ if ( this . # context. definition . interruptOnSpans ) {
381
+ for ( const doesSpanMatch of this . # context. definition
382
382
. interruptOnSpans ) {
383
- if ( doesSpanMatch ( spanAndAnnotation , this . context ) ) {
383
+ if ( doesSpanMatch ( spanAndAnnotation , this . # context) ) {
384
384
return {
385
385
transitionToState : 'interrupted' ,
386
386
interruptionReason : doesSpanMatch . requiredSpan
@@ -391,15 +391,19 @@ export class TraceStateMachine<
391
391
}
392
392
}
393
393
394
- for ( let i = 0 ; i < this . context . definition . requiredSpans . length ; i ++ ) {
394
+ for (
395
+ let i = 0 ;
396
+ i < this . #context. definition . requiredSpans . length ;
397
+ i ++
398
+ ) {
395
399
if ( ! this . remainingRequiredSpanIndexes . has ( i ) ) {
396
400
// we previously checked off this index
397
401
// eslint-disable-next-line no-continue
398
402
continue
399
403
}
400
404
401
- const doesSpanMatch = this . context . definition . requiredSpans [ i ] !
402
- if ( doesSpanMatch ( spanAndAnnotation , this . context ) ) {
405
+ const doesSpanMatch = this . # context. definition . requiredSpans [ i ] !
406
+ if ( doesSpanMatch ( spanAndAnnotation , this . # context) ) {
403
407
// remove the index of this definition from the list of requiredSpans
404
408
this . remainingRequiredSpanIndexes . delete ( i )
405
409
@@ -459,15 +463,15 @@ export class TraceStateMachine<
459
463
this . lastRequiredSpan = this . lastRelevant
460
464
this . lastRequiredSpan . annotation . markedRequirementsMet = true
461
465
462
- if ( ! this . context . definition . debounceOnSpans ) {
466
+ if ( ! this . # context. definition . debounceOnSpans ) {
463
467
return { transitionToState : 'waiting-for-interactive' }
464
468
}
465
469
// set the first debounce deadline
466
470
this . setDeadline (
467
471
'debounce' ,
468
472
this . lastRelevant . span . startTime . epoch +
469
473
this . lastRelevant . span . duration +
470
- ( this . context . definition . debounceWindow ??
474
+ ( this . # context. definition . debounceWindow ??
471
475
DEFAULT_DEBOUNCE_DURATION ) ,
472
476
)
473
477
@@ -528,9 +532,9 @@ export class TraceStateMachine<
528
532
span : { ...span , isIdle : true } ,
529
533
}
530
534
if ( idleRegressionCheckSpan ) {
531
- for ( const doesSpanMatch of this . context . definition . requiredSpans ) {
535
+ for ( const doesSpanMatch of this . # context. definition . requiredSpans ) {
532
536
if (
533
- doesSpanMatch ( idleRegressionCheckSpan , this . context ) &&
537
+ doesSpanMatch ( idleRegressionCheckSpan , this . # context) &&
534
538
doesSpanMatch . idleCheck
535
539
) {
536
540
// check if we regressed on "isIdle", and if so, transition to interrupted with reason
@@ -545,9 +549,10 @@ export class TraceStateMachine<
545
549
this . sideEffectFns . addSpanToRecording ( spanAndAnnotation )
546
550
547
551
// does span satisfy any of the "debouncedOn" and if so, restart our debounce timer
548
- if ( this . context . definition . debounceOnSpans ) {
549
- for ( const doesSpanMatch of this . context . definition . debounceOnSpans ) {
550
- if ( doesSpanMatch ( spanAndAnnotation , this . context ) ) {
552
+ if ( this . #context. definition . debounceOnSpans ) {
553
+ for ( const doesSpanMatch of this . #context. definition
554
+ . debounceOnSpans ) {
555
+ if ( doesSpanMatch ( spanAndAnnotation , this . #context) ) {
551
556
// Sometimes spans are processed out of order, we update the lastRelevant if this span ends later
552
557
if (
553
558
spanAndAnnotation . annotation . operationRelativeEndTime >
@@ -561,7 +566,7 @@ export class TraceStateMachine<
561
566
'debounce' ,
562
567
this . lastRelevant . span . startTime . epoch +
563
568
this . lastRelevant . span . duration +
564
- ( this . context . definition . debounceWindow ??
569
+ ( this . # context. definition . debounceWindow ??
565
570
DEFAULT_DEBOUNCE_DURATION ) ,
566
571
)
567
572
}
@@ -590,7 +595,7 @@ export class TraceStateMachine<
590
595
}
591
596
592
597
this . completeSpan = this . lastRelevant
593
- const interactiveConfig = this . context . definition . captureInteractive
598
+ const interactiveConfig = this . # context. definition . captureInteractive
594
599
if ( ! interactiveConfig ) {
595
600
// nothing to do in this state, move to 'complete'
596
601
return {
@@ -766,10 +771,10 @@ export class TraceStateMachine<
766
771
767
772
// if the entry matches any of the interruptOnSpans criteria,
768
773
// transition to complete state with the 'matched-on-interrupt' interruptionReason
769
- if ( this . context . definition . interruptOnSpans ) {
770
- for ( const doesSpanMatch of this . context . definition
774
+ if ( this . # context. definition . interruptOnSpans ) {
775
+ for ( const doesSpanMatch of this . # context. definition
771
776
. interruptOnSpans ) {
772
- if ( doesSpanMatch ( spanAndAnnotation , this . context ) ) {
777
+ if ( doesSpanMatch ( spanAndAnnotation , this . # context) ) {
773
778
return {
774
779
transitionToState : 'complete' ,
775
780
interruptionReason : doesSpanMatch . requiredSpan
@@ -1147,13 +1152,15 @@ export class Trace<
1147
1152
definition : this . definition ,
1148
1153
// only keep items captured until the endOfOperationSpan
1149
1154
recordedItems : endOfOperationSpan
1150
- ? [ ...this . recordedItems ] . filter (
1151
- ( item ) =>
1152
- item . span . startTime . now + item . span . duration <=
1153
- endOfOperationSpan . span . startTime . now +
1154
- endOfOperationSpan . span . duration ,
1155
+ ? new Set (
1156
+ [ ...this . recordedItems ] . filter (
1157
+ ( item ) =>
1158
+ item . span . startTime . now + item . span . duration <=
1159
+ endOfOperationSpan . span . startTime . now +
1160
+ endOfOperationSpan . span . duration ,
1161
+ ) ,
1155
1162
)
1156
- : [ ... this . recordedItems ] ,
1163
+ : this . recordedItems ,
1157
1164
input : this . input ,
1158
1165
recordedItemsByLabel : this . recordedItemsByLabel ,
1159
1166
} ,
0 commit comments