feat: record first token latency in runtime router

This commit is contained in:
John
2026-07-02 07:45:47 +08:00
parent 41b7b5ffa3
commit 8e5094fcd9
4 changed files with 86 additions and 3 deletions
+5
View File
@@ -155,6 +155,10 @@ function summarizeRuntime(runtimeJson) {
streamOpenCount: worker.streamOpenCount,
streamAbortCount: worker.streamAbortCount,
streamErrorCount: worker.streamErrorCount,
ewmaFirstTokenMs: worker.ewmaFirstTokenMs,
lastFirstTokenMs: worker.lastFirstTokenMs,
lastFirstTokenAt: worker.lastFirstTokenAt,
firstTokenCount: worker.firstTokenCount,
cpuLoad: worker.cpuLoad,
memoryPressure: worker.memoryPressure,
fdPressure: worker.fdPressure,
@@ -213,6 +217,7 @@ for (const worker of runtimeSummary?.workers ?? []) {
if (worker.containerHealth && worker.containerHealth !== 'healthy') failures.push(`${worker.id}_container_${worker.containerHealth}`);
if (!worker.metricsFresh) failures.push(`${worker.id}_metrics_stale`);
if (worker.streamErrorCount > 0) failures.push(`${worker.id}_stream_errors_${worker.streamErrorCount}`);
if (worker.firstTokenCount > 0 && worker.ewmaFirstTokenMs <= 0) failures.push(`${worker.id}_first_token_ewma_missing`);
}
if (runtimeSummary?.toolRuntime?.chatInjectsCodeTools !== false) failures.push('chat_injects_code_tools');