feat: expose sub2api timeout timing diagnostics

This commit is contained in:
Codex
2026-07-14 06:51:24 +02:00
parent a91238c200
commit b9ede0471e
6 changed files with 265 additions and 5 deletions
@@ -401,6 +401,8 @@ export function renderTraceReport(
const forwardFailures = recordArray(parsed.forwardFailures);
const tempUnschedulable = recordArray(parsed.tempUnschedulable);
const windowStats = isRecord(parsed.windowStats) ? parsed.windowStats : {};
const diagnostics = isRecord(parsed.diagnostics) ? parsed.diagnostics : {};
const timing = isRecord(diagnostics.timing) ? diagnostics.timing : {};
const logs = isRecord(parsed.logs) ? parsed.logs : {};
const accountSnapshot = recordArray(parsed.accountSnapshot);
const lines: string[] = [];
@@ -439,13 +441,23 @@ export function renderTraceReport(
`events=${textValue(summary.eventCount)}`,
`window=${window.beforeSeconds ?? "?"}s/${window.afterSeconds ?? "?"}s`,
].join(" "));
lines.push(renderTable([
["TIME_REF", "FIRST_FAILOVER_MS", "SELECT_FAILED_MS", "FINAL_MS", "FAILOVER_TO_FINAL_MS", "CLIENT_DEADLINE", "REMAINING_MS"],
[
textValue(timing.referenceSource), textValue(timing.firstFailoverElapsedMs), textValue(timing.firstSelectFailedElapsedMs),
textValue(timing.finalElapsedMs), textValue(timing.failoverToFinalMs), timing.clientDeadlineAvailable === true ? "available" : "unavailable",
textValue(timing.clientDeadlineRemainingMs),
],
]));
if (typeof timing.attribution === "string") lines.push(`NOTE: ${timing.attribution}`);
if (failovers.length > 0) {
lines.push("");
lines.push("FAILOVER");
lines.push(renderTable([
["AT", "ACCOUNT", "UPSTREAM", "SWITCH", "MAX"],
["AT", "ELAPSED_MS", "ACCOUNT", "UPSTREAM", "SWITCH", "MAX"],
...failovers.map((item) => [
shortIso(item.at),
textValue(item.elapsedMs),
formatAccountRef(item),
textValue(item.upstreamStatus),
textValue(item.switchCount),
@@ -457,9 +469,10 @@ export function renderTraceReport(
lines.push("");
lines.push("SELECT-FAILED");
lines.push(renderTable([
["AT", "ERROR", "EXCLUDED"],
["AT", "ELAPSED_MS", "ERROR", "EXCLUDED"],
...selectFailures.map((item) => [
shortIso(item.at),
textValue(item.elapsedMs),
shorten(stringValue(item.error) ?? "-", 56),
textValue(item.excludedAccountCount),
]),
@@ -469,9 +482,10 @@ export function renderTraceReport(
lines.push("");
lines.push("FORWARD-FAILED");
lines.push(renderTable([
["AT", "ACCOUNT", "STATUS", "ERROR"],
["AT", "ELAPSED_MS", "ACCOUNT", "STATUS", "ERROR"],
...forwardFailures.map((item) => [
shortIso(item.at),
textValue(item.elapsedMs),
formatAccountRef(item),
textValue(item.statusCode),
shorten(stringValue(item.error) ?? "-", 72),