Skip to content

Commit c1c2335

Browse files
committed
fix: improve consistency of naming
1 parent a0e430a commit c1c2335

15 files changed

+139
-124
lines changed

src/stories/mockComponentsv3/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ const ticketOperationTracer = traceManager.createTracer({
3838
],
3939
scopes: ['ticketId'],
4040
variants: {
41-
click: { timeoutDuration: 45_000 },
41+
click: { timeout: 45_000 },
4242
},
43-
// debounceDuration: 1_000,
44-
debounceOn: [
43+
// debounceWindow: 1_000,
44+
debounceOnSpans: [
4545
{
4646
name: 'TicketView',
4747
matchScopes: ['ticketId'],
4848
},
4949
],
50-
interruptOn: [
50+
interruptOnSpans: [
5151
{
5252
name: 'TicketView',
5353
matchScopes: ['ticketId'],

src/v3/ActiveTrace.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class TraceStateMachine<
273273
this.setGlobalDeadline(
274274
this.context.input.startTime.epoch +
275275
this.context.definition.variants[this.context.input.variant]!
276-
.timeoutDuration,
276+
.timeout,
277277
)
278278
},
279279

@@ -299,10 +299,11 @@ export class TraceStateMachine<
299299
}
300300
}
301301

302-
// if the entry matches any of the interruptOn criteria,
302+
// if the entry matches any of the interruptOnSpans criteria,
303303
// transition to complete state with the 'matched-on-interrupt' interruptionReason
304-
if (this.context.definition.interruptOn) {
305-
for (const doesSpanMatch of this.context.definition.interruptOn) {
304+
if (this.context.definition.interruptOnSpans) {
305+
for (const doesSpanMatch of this.context.definition
306+
.interruptOnSpans) {
306307
if (doesSpanMatch(spanAndAnnotation, this.context)) {
307308
return {
308309
transitionToState: 'complete',
@@ -361,9 +362,9 @@ export class TraceStateMachine<
361362
}
362363
}
363364

364-
// does span satisfy any of the "interruptOn" definitions
365-
if (this.context.definition.interruptOn) {
366-
for (const match of this.context.definition.interruptOn) {
365+
// does span satisfy any of the "interruptOnSpans" definitions
366+
if (this.context.definition.interruptOnSpans) {
367+
for (const match of this.context.definition.interruptOnSpans) {
367368
if (match(spanAndAnnotation, this.context)) {
368369
return {
369370
transitionToState: 'interrupted',
@@ -441,15 +442,15 @@ export class TraceStateMachine<
441442
this.lastRequiredSpan = this.lastRelevant
442443
this.lastRequiredSpan.annotation.markedRequirementsMet = true
443444

444-
if (!this.context.definition.debounceOn) {
445+
if (!this.context.definition.debounceOnSpans) {
445446
return { transitionToState: 'waiting-for-interactive' }
446447
}
447448
// set the first debounce deadline
448449
this.setDeadline(
449450
'debounce',
450451
this.lastRelevant.span.startTime.epoch +
451452
this.lastRelevant.span.duration +
452-
(this.context.definition.debounceDuration ??
453+
(this.context.definition.debounceWindow ??
453454
DEFAULT_DEBOUNCE_DURATION),
454455
)
455456

@@ -527,8 +528,8 @@ export class TraceStateMachine<
527528
this.sideEffectFns.addSpanToRecording(spanAndAnnotation)
528529

529530
// does span satisfy any of the "debouncedOn" and if so, restart our debounce timer
530-
if (this.context.definition.debounceOn) {
531-
for (const doesSpanMatch of this.context.definition.debounceOn) {
531+
if (this.context.definition.debounceOnSpans) {
532+
for (const doesSpanMatch of this.context.definition.debounceOnSpans) {
532533
if (doesSpanMatch(spanAndAnnotation, this.context)) {
533534
// Sometimes spans are processed out of order, we update the lastRelevant if this span ends later
534535
if (
@@ -543,7 +544,7 @@ export class TraceStateMachine<
543544
'debounce',
544545
this.lastRelevant.span.startTime.epoch +
545546
this.lastRelevant.span.duration +
546-
(this.context.definition.debounceDuration ??
547+
(this.context.definition.debounceWindow ??
547548
DEFAULT_DEBOUNCE_DURATION),
548549
)
549550
}
@@ -746,10 +747,11 @@ export class TraceStateMachine<
746747
}
747748
}
748749

749-
// if the entry matches any of the interruptOn criteria,
750+
// if the entry matches any of the interruptOnSpans criteria,
750751
// transition to complete state with the 'matched-on-interrupt' interruptionReason
751-
if (this.context.definition.interruptOn) {
752-
for (const doesSpanMatch of this.context.definition.interruptOn) {
752+
if (this.context.definition.interruptOnSpans) {
753+
for (const doesSpanMatch of this.context.definition
754+
.interruptOnSpans) {
753755
if (doesSpanMatch(spanAndAnnotation, this.context)) {
754756
return {
755757
transitionToState: 'complete',
@@ -959,13 +961,13 @@ export class ActiveTrace<
959961
computedSpanDefinitions: [...definition.computedSpanDefinitions],
960962
computedValueDefinitions: [...definition.computedValueDefinitions],
961963

962-
interruptOn: definition.interruptOn
963-
? [...definition.interruptOn]
964+
interruptOnSpans: definition.interruptOnSpans
965+
? [...definition.interruptOnSpans]
964966
: undefined,
965-
debounceOn: definition.debounceOn
966-
? [...definition.debounceOn]
967+
debounceOnSpans: definition.debounceOnSpans
968+
? [...definition.debounceOnSpans]
967969
: undefined,
968-
debounceDuration: definition.debounceDuration,
970+
debounceWindow: definition.debounceWindow,
969971
captureInteractive: definition.captureInteractive
970972
? typeof definition.captureInteractive === 'boolean'
971973
? definition.captureInteractive
@@ -1113,10 +1115,10 @@ export class ActiveTrace<
11131115
] as (typeof definition)['requiredSpans']
11141116
}
11151117
if (additionalDebounceOnSpans?.length) {
1116-
definition.debounceOn = [
1117-
...(this.sourceDefinition.debounceOn ?? []),
1118+
definition.debounceOnSpans = [
1119+
...(this.sourceDefinition.debounceOnSpans ?? []),
11181120
...additionalDebounceOnSpans,
1119-
] as (typeof definition)['debounceOn']
1121+
] as (typeof definition)['debounceOnSpans']
11201122
}
11211123
}
11221124

src/v3/convertToRum.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('convertTraceToRUM', () => {
1818
computedSpanDefinitions: [],
1919
computedValueDefinitions: [],
2020
variants: {
21-
origin: { timeoutDuration: 45_000 },
21+
origin: { timeout: 45_000 },
2222
},
2323
}
2424

src/v3/idealApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ export const ticketActivationTracer = traceManager.createOperationTracer({
122122
},
123123
],
124124
// we do not need to debounce on anything until 'requiredToEnd' is met
125-
debounceOn: [
125+
debounceOnSpans: [
126126
{
127127
match: { scope: { ticket: { id } } },
128128
}
129129
],
130-
interruptOn: [
130+
interruptOnSpans: [
131131
{
132132
match: {
133133
type: 'mark',

src/v3/matchSpan.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const mockContext = {
8585
computedSpanDefinitions: [],
8686
computedValueDefinitions: [],
8787
variants: {
88-
origin: { timeoutDuration: 10_000 },
88+
origin: { timeout: 10_000 },
8989
},
9090
} satisfies CompleteTraceDefinition<'ticketId', TicketScope, 'origin'>,
9191
} as const

src/v3/recordingComputeUtils.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('recordingComputeUtils', () => {
2222
computedSpanDefinitions: [],
2323
computedValueDefinitions: [],
2424
variants: {
25-
origin: { timeoutDuration: 45_000 },
25+
origin: { timeout: 45_000 },
2626
},
2727
}
2828

@@ -159,7 +159,7 @@ describe('recordingComputeUtils', () => {
159159
],
160160
computedValueDefinitions: [],
161161
variants: {
162-
origin: { timeoutDuration: 45_000 },
162+
origin: { timeout: 45_000 },
163163
},
164164
}
165165

@@ -241,7 +241,7 @@ describe('recordingComputeUtils', () => {
241241
},
242242
],
243243
variants: {
244-
origin: { timeoutDuration: 45_000 },
244+
origin: { timeout: 45_000 },
245245
},
246246
}
247247

@@ -297,7 +297,7 @@ describe('recordingComputeUtils', () => {
297297
computedSpanDefinitions: [],
298298
computedValueDefinitions: [],
299299
variants: {
300-
origin: { timeoutDuration: 45_000 },
300+
origin: { timeout: 45_000 },
301301
},
302302
},
303303
recordedItems: [

src/v3/testUtility/fixtures/ticket.activation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const ticketActivationDefinition: TraceDefinition<
2121
type: 'operation',
2222
scopes: ['ticketId'],
2323
variants: {
24-
cold_boot: { timeoutDuration: 60_000 },
24+
cold_boot: { timeout: 60_000 },
2525
},
2626
captureInteractive: true,
2727
requiredSpans: [
@@ -32,7 +32,7 @@ export const ticketActivationDefinition: TraceDefinition<
3232
isIdle: true,
3333
},
3434
],
35-
interruptOn: [
35+
interruptOnSpans: [
3636
{
3737
type: 'mark',
3838
name: TICKET_DISPOSE_EVENT_NAME,
@@ -44,7 +44,7 @@ export const ticketActivationDefinition: TraceDefinition<
4444
matchScopes: ['ticketId'],
4545
},
4646
],
47-
debounceOn: [
47+
debounceOnSpans: [
4848
// debounce on anything that has matching ticketId scope:
4949
{ matchScopes: ['ticketId'] },
5050
// TODO: { type: 'measure', name: (name, scope) => `ticket/${scope.ticketId}/open` },

src/v3/traceManager.test.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('TraceManager', () => {
5454
scopes: ['ticketId'],
5555
requiredSpans: [{ name: 'end' }],
5656
variants: {
57-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
57+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
5858
},
5959
})
6060
const traceId = tracer.start({
@@ -101,7 +101,7 @@ describe('TraceManager', () => {
101101
scopes: [],
102102
requiredSpans: [{ name: 'end' }],
103103
variants: {
104-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
104+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
105105
},
106106
})
107107

@@ -161,7 +161,7 @@ describe('TraceManager', () => {
161161
scopes: [],
162162
requiredSpans: [{ name: 'end' }],
163163
variants: {
164-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
164+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
165165
},
166166
})
167167

@@ -221,7 +221,7 @@ describe('TraceManager', () => {
221221
scopes: [],
222222
requiredSpans: [{ name: 'Component', isIdle: true }],
223223
variants: {
224-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
224+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
225225
},
226226
})
227227

@@ -281,7 +281,7 @@ describe('TraceManager', () => {
281281
scopes: ['ticketId'],
282282
requiredSpans: [{ name: 'end', matchScopes: true }],
283283
variants: {
284-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
284+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
285285
},
286286
})
287287
const scope = {
@@ -332,9 +332,9 @@ describe('TraceManager', () => {
332332
type: 'operation',
333333
scopes: [],
334334
requiredSpans: [{ name: 'end' }],
335-
debounceOn: [{ name: 'debounce' }],
335+
debounceOnSpans: [{ name: 'debounce' }],
336336
variants: {
337-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
337+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
338338
},
339339
})
340340
const traceId = tracer.start({
@@ -381,10 +381,12 @@ describe('TraceManager', () => {
381381
type: 'operation',
382382
scopes: [],
383383
requiredSpans: [matchSpan.withName('end')],
384-
debounceOn: [matchSpan.withName((n: string) => n.endsWith('debounce'))],
385-
debounceDuration: 300,
384+
debounceOnSpans: [
385+
matchSpan.withName((n: string) => n.endsWith('debounce')),
386+
],
387+
debounceWindow: 300,
386388
variants: {
387-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
389+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
388390
},
389391
})
390392
tracer.start({
@@ -423,7 +425,7 @@ describe('TraceManager', () => {
423425
})
424426

425427
describe('interrupts', () => {
426-
it('interrupts a basic trace when interruptOn criteria is met', () => {
428+
it('interrupts a basic trace when interruptOnSpans criteria is met', () => {
427429
const traceManager = new TraceManager<TicketScope>({
428430
reportFn,
429431
generateId,
@@ -434,9 +436,9 @@ describe('TraceManager', () => {
434436
type: 'operation',
435437
scopes: [],
436438
requiredSpans: [matchSpan.withName('end')],
437-
interruptOn: [matchSpan.withName('interrupt')],
439+
interruptOnSpans: [matchSpan.withName('interrupt')],
438440
variants: {
439-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
441+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
440442
},
441443
})
442444
tracer.start({
@@ -484,9 +486,9 @@ describe('TraceManager', () => {
484486
type: 'operation',
485487
scopes: [],
486488
requiredSpans: [{ name: 'end' }],
487-
debounceOn: [{ name: 'debounce' }],
489+
debounceOnSpans: [{ name: 'debounce' }],
488490
variants: {
489-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
491+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
490492
},
491493
})
492494
const traceId = tracer.start({
@@ -543,9 +545,9 @@ describe('TraceManager', () => {
543545
type: 'operation',
544546
scopes: [],
545547
requiredSpans: [{ name: 'end', isIdle: true }],
546-
debounceOn: [{ name: 'end' }],
548+
debounceOnSpans: [{ name: 'end' }],
547549
variants: {
548-
cold_boot: { timeoutDuration: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
550+
cold_boot: { timeout: DEFAULT_COLDBOOT_TIMEOUT_DURATION },
549551
},
550552
})
551553
tracer.start({
@@ -595,7 +597,7 @@ describe('TraceManager', () => {
595597
type: 'operation',
596598
scopes: ['ticketId'],
597599
requiredSpans: [{ name: 'timed-out-render' }],
598-
variants: { cold_boot: { timeoutDuration: 500 } },
600+
variants: { cold_boot: { timeout: 500 } },
599601
})
600602
const traceId = tracer.start({
601603
startTime: { now: 0, epoch: 0 },
@@ -650,7 +652,7 @@ describe('TraceManager', () => {
650652
scopes: [],
651653
requiredSpans: [{ name: 'timed-out-render' }],
652654
variants: {
653-
cold_boot: { timeoutDuration: CUSTOM_TIMEOUT_DURATION },
655+
cold_boot: { timeout: CUSTOM_TIMEOUT_DURATION },
654656
},
655657
})
656658
const traceId = tracer.start({
@@ -701,9 +703,9 @@ describe('TraceManager', () => {
701703
type: 'operation',
702704
scopes: [],
703705
requiredSpans: [{ name: 'end' }],
704-
debounceOn: [{ name: 'debounce' }],
706+
debounceOnSpans: [{ name: 'debounce' }],
705707
variants: {
706-
cold_boot: { timeoutDuration: CUSTOM_TIMEOUT_DURATION },
708+
cold_boot: { timeout: CUSTOM_TIMEOUT_DURATION },
707709
},
708710
})
709711
const traceId = tracer.start({

0 commit comments

Comments
 (0)