Skip to content

Commit

Permalink
test: update tests and feat: add completeTillInteractive computaton
Browse files Browse the repository at this point in the history
  • Loading branch information
xnanodax committed Nov 23, 2024
1 parent c69a7ec commit 1f5d223
Show file tree
Hide file tree
Showing 3 changed files with 414 additions and 62 deletions.
18 changes: 9 additions & 9 deletions src/v3/recordingComputeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ export function getComputedSpans<ScopeT extends ScopeBase>({
startSpanMatcher === 'operation-start'
? input.startTime.now
: recordedItems.find((spanAndAnnotation) =>
startSpanMatcher(spanAndAnnotation, input.scope),
)?.span.startTime.now
startSpanMatcher(spanAndAnnotation, input.scope),
)?.span.startTime.now

const endSpanMatcher =
endSpan === 'operation-end'
? markedComplete
: endSpan === 'interactive'
? markedInteractive
: endSpan
? markedInteractive
: endSpan

const matchingEndEntry = recordedItems.find((spanAndAnnotation) =>
endSpanMatcher(spanAndAnnotation, input.scope),
Expand Down Expand Up @@ -161,23 +161,23 @@ export function createTraceRecording<ScopeT extends ScopeBase>(
const anyErrors = recordedItems.some(({ span }) => span.status === 'error')
const duration =
lastRequiredSpanAndAnnotation?.annotation.operationRelativeEndTime ?? null
const startTillInteractive = cpuIdleSpanAndAnnotation?.annotation.operationRelativeEndTime ?? null
return {
id,
name,
scope,
type: 'operation',
duration,
startTillInteractive:
cpuIdleSpanAndAnnotation?.annotation.operationRelativeEndTime ?? null,
startTillInteractive,
// last entry until the tti?
completeTillInteractive: 0,
completeTillInteractive: startTillInteractive && duration ? startTillInteractive - duration : null,
// ?: If we have any error entries then should we mark the status as 'error'
status:
wasInterrupted
? 'interrupted'
: anyErrors
? 'error'
: 'ok',
? 'error'
: 'ok',
computedSpans,
computedValues,
attributes,
Expand Down
3 changes: 1 addition & 2 deletions src/v3/test/processEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ function processEntries<ScopeT extends ScopeBase>(entries: PerformanceEntry[], t
duration: entry.duration,
isIdle: entry.name.includes('idle'),
renderedOutput: entry.name.includes('idle') ? 'content' : 'loading',
// startTime: ensureTimestamp({ now: entry.startTime }),
startTime: ensureTimestamp(),
startTime: ensureTimestamp({ now: entry.startTime }),
type: entry.entryType as SpanType,
performanceEntry: entry,
scope: {},
Expand Down
Loading

0 comments on commit 1f5d223

Please sign in to comment.