fix(workbench): stabilize running timing start (#1982)
Co-authored-by: root <root@lyon.remote>
This commit is contained in:
@@ -907,9 +907,10 @@ function factTraceTimingProjection(events = [], checkpoint = null, status = null
|
||||
const normalizedStatus = normalizeStatus(status ?? checkpoint?.status);
|
||||
const terminal = TERMINAL_STATUSES.has(normalizedStatus) && !RUNNING_STATUSES.has(normalizedStatus);
|
||||
const observedAt = new Date().toISOString();
|
||||
const eventTimes = factArray(events).flatMap((event) => [event?.createdAt, event?.updatedAt, event?.occurredAt]);
|
||||
const startedAt = firstTimestampIso(checkpointTiming.startedAt, ...eventTimes);
|
||||
const lastEventAt = latestTimestampIso(checkpointTiming.lastEventAt, ...eventTimes);
|
||||
const eventStartTimes = factArray(events).flatMap((event) => [event?.createdAt, event?.occurredAt]);
|
||||
const eventActivityTimes = factArray(events).flatMap((event) => [event?.createdAt, event?.occurredAt, event?.updatedAt]);
|
||||
const startedAt = firstTimestampIso(checkpointTiming.startedAt, ...eventStartTimes);
|
||||
const lastEventAt = latestTimestampIso(checkpointTiming.lastEventAt, ...eventActivityTimes);
|
||||
const finishedAt = terminal ? latestTimestampIso(checkpointTiming.finishedAt, lastEventAt) : null;
|
||||
const durationMs = elapsedFactMs(startedAt, terminal ? finishedAt : observedAt);
|
||||
const lastEventAgeMs = terminal ? null : elapsedFactMs(lastEventAt, observedAt);
|
||||
@@ -984,7 +985,7 @@ function factProjectionForTrace(facts = {}, traceId) {
|
||||
function factTimingProjection(record = null, status = null) {
|
||||
const source = objectValue(record?.timing);
|
||||
const observedAt = new Date().toISOString();
|
||||
const startedAt = timestampIso(source?.startedAt ?? record?.startedAt);
|
||||
const startedAt = timestampIso(source?.startedAt ?? record?.startedAt ?? record?.createdAt);
|
||||
const lastEventAt = timestampIso(source?.lastEventAt ?? record?.lastEventAt ?? record?.updatedAt ?? record?.createdAt);
|
||||
const normalizedStatus = normalizeStatus(status ?? record?.status);
|
||||
const terminal = record?.terminal === true || TERMINAL_STATUSES.has(normalizedStatus) && !RUNNING_STATUSES.has(normalizedStatus);
|
||||
@@ -1011,7 +1012,7 @@ function factTimingSource(record = null) {
|
||||
if (!record) return null;
|
||||
const source = objectValue(record?.timing);
|
||||
return {
|
||||
startedAt: timestampIso(source?.startedAt ?? record?.startedAt),
|
||||
startedAt: timestampIso(source?.startedAt ?? record?.startedAt ?? record?.createdAt),
|
||||
lastEventAt: timestampIso(source?.lastEventAt ?? record?.lastEventAt ?? record?.updatedAt ?? record?.createdAt),
|
||||
finishedAt: timestampIso(source?.finishedAt ?? record?.finishedAt ?? record?.completedAt)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user