persist gateway metrics across restarts

This commit is contained in:
2026-06-29 16:54:29 +08:00
parent 283c14b6b4
commit 5f6fb3504d
5 changed files with 95 additions and 16 deletions
+5 -3
View File
@@ -23,6 +23,7 @@ type GatewayConfig = {
type Metrics = {
started_at?: string;
persistent_since?: string | null;
total_proxy_request_count?: number;
inspected_response_count?: number;
matched_response_count?: number;
@@ -230,7 +231,7 @@ type ProfileProbePayload = {
const pageCopy: Record<PageKey, { title: string; subtitle: string; index: string }> = {
overview: {
title: "概览",
subtitle: "当前 gateway 运行态和本次启动以来的累计统计。",
subtitle: "当前 gateway 运行态,以及基于持久请求记录回灌的累计统计。",
index: "01",
},
requests: {
@@ -808,7 +809,7 @@ export default function App() {
</div>
</Card>
<Card title="Token Totals" hint="按本次 gateway 启动以来累计;后续可以接持久化统计。">
<Card title="Token Totals" hint="按持久请求记录累计;重启后会从 requests history 回灌。">
<div className="token-strip">
<TokenCard label="Input" value={numberFormat(effectiveInputTotal ?? 0)} />
<TokenCard label="Output" value={numberFormat(tokens.output_tokens || 0)} />
@@ -839,7 +840,8 @@ export default function App() {
rows={[
["516 命中", numberFormat(metrics.reasoning_516_count || 0)],
["516 占比", percent(metrics.reasoning_516_ratio || 0)],
["启动时间", timestamp(metrics.started_at)],
["累计起点", timestamp(metrics.persistent_since || metrics.started_at)],
["本次启动", timestamp(metrics.started_at)],
["Config", status?.paths?.config_path || "-"],
["备份", status?.state?.latest_backup_path || "-"],
]}