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
+3 -3
View File
@@ -202,7 +202,7 @@ gateway 运行时只负责 API 与静态文件服务,不再把复杂 UI 硬写
页面里可以直接做这几件事:
- 看当前监听地址、真实上游、当前 provider、当前 Codex base URL
-本次 gateway 启动以来的实时统计
-基于持久请求记录累计的实时统计
- 代理请求总数
- 被检查响应总数
- 累计 input / output / total / reasoning tokens
@@ -229,11 +229,11 @@ gateway 运行时只负责 API 与静态文件服务,不再把复杂 UI 硬写
- 页面点“恢复 Codex 原设置并关闭网关”后,当前页面会失联,这是预期行为
- 日常恢复优先用 UI`restore-codex-config.ps1` 作为脚本级应急回滚入口保留
- UI 恢复不会再额外拉起恢复子进程,而是由当前 gateway 直接完成恢复并退出
- 统计口径默认按“本次 gateway 启动以来”累计
- 统计口径默认按持久请求记录累计,重启后会从 `requests.sqlite` / `requests.jsonl` 回灌
- `516` 占比 = `reasoning_tokens = 516` 的响应次数 / 被检查响应总数
- 请求历史只记录元数据、请求体字节数和 token usage,不保存请求正文或响应正文;默认展示最近 200 条
- gateway 日志持久化到 `~/.codex-retry-gateway/logs/gateway.log`
- 请求记录持久化到 `~/.codex-retry-gateway/logs/requests.jsonl`,重启后仍可用于 UI 请求页和 token totals
- 请求记录持久化到 `~/.codex-retry-gateway/logs/requests.jsonl``~/.codex-retry-gateway/logs/requests.sqlite`,重启后用于 UI 请求页以及 overview 的累计 token / reasoning 统计
- `manual_bearer` 的手动 token/password 只写入系统 secret 文件,API/UI 不读回明文;profile env 只保存 secret 文件路径
- 其他 profile env 不保存明文 `sk-...`;固定密钥请使用 env/file 引用,或用 `auth_json` 指向 `auth.json` 字段名