feat(logs): 调用日志列表加「缓存命中」列(量 + 命中率)
数据本来就有(tok_cached/tok_prompt),只是列表没显示:命中率此前只在详情弹窗里。 - 列表新增列:命中量(k/M 缩写)+ 命中率%(按档位配色) - 实测 107 条带 token 记录:命中 62 条,中位 83.9%,最高 99.7% - 版本 2.9.8 → 2.9.9
This commit is contained in:
1 parent
2b15db905b
commit
49e69bf5ad
5 files changed
+53
-1
No files matched your search
@@ -1,5 +1,23 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 2026-10-23 · 调用日志列表加「缓存命中」列(2.9.8 → 2.9.9)
|
||||||
|
|
||||||
|
老板:「调用日志的命中缓存率为什么一直都是 0」。
|
||||||
|
|
||||||
|
**先给结论:数据没坏,是列表上看不到这一列。** 缓存命中率一直只在**详情弹窗**里显示,
|
||||||
|
列表没有;而 admin 自己那几条测试请求都是 38~41 token 的短提示词,上游不会缓存 →
|
||||||
|
所以看起来"一直是 0"。真实业务的调用是命中的。
|
||||||
|
|
||||||
|
实测(同一时刻库里的 107 条带 token 记录):
|
||||||
|
- **命中 62 条 / 未命中 45 条**
|
||||||
|
- 命中组:最低 11.1%、**中位 83.9%**、最高 99.7%
|
||||||
|
- 未命中组:输入 38 ~ 60192 token(短提示词不触发上游缓存;长提示词的前缀不一致也不命中)
|
||||||
|
|
||||||
|
改动:
|
||||||
|
- 调用日志列表新增「缓存命中」列(在耗时之后):显示 `命中量 / 命中率%`,
|
||||||
|
量按 k/M 缩写,命中率按档位配色(≥50% 绿、>0 黄、0 淡显)。
|
||||||
|
- 数据直接取列表接口已返回的 `tok_cached` / `tok_prompt`,无额外查询。
|
||||||
|
|
||||||
## 2026-10-23 · 视频轮询时间线落库(2.9.7 → 2.9.8)
|
## 2026-10-23 · 视频轮询时间线落库(2.9.7 → 2.9.8)
|
||||||
|
|
||||||
老板:「视频任务的轮询时间线也要落库」。
|
老板:「视频任务的轮询时间线也要落库」。
|
||||||
|
|||||||
+1
-1
@@ -355,7 +355,7 @@ _docs_on = config.server.docs_enabled # 安全默认关(report: /docs、/ope
|
|||||||
# 2026-09-30: 2.6.1 → 2.7.0(按老板要求整个删除「火山方舟 Coding Plan」供应商:配置/模型/代码/文档/前端下拉/环境变量全清)。
|
# 2026-09-30: 2.6.1 → 2.7.0(按老板要求整个删除「火山方舟 Coding Plan」供应商:配置/模型/代码/文档/前端下拉/环境变量全清)。
|
||||||
# 2026-09-30: 2.7.0 → 2.7.1(界面提示白话化:熔断器→供应商自动保护、引擎→运行环境、slug→标识;删 120 个未引用死键)。
|
# 2026-09-30: 2.7.0 → 2.7.1(界面提示白话化:熔断器→供应商自动保护、引擎→运行环境、slug→标识;删 120 个未引用死键)。
|
||||||
# ★ 版本号纪律:每次改动都要往上加,小改动加小版本号、大改动加大版本号(README 有专章)。
|
# ★ 版本号纪律:每次改动都要往上加,小改动加小版本号、大改动加大版本号(README 有专章)。
|
||||||
VERSION = "2.9.8"
|
VERSION = "2.9.9"
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="API Gateway",
|
title="API Gateway",
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ export default {
|
|||||||
colFailRate: 'Fail rate',
|
colFailRate: 'Fail rate',
|
||||||
colModels: 'Models',
|
colModels: 'Models',
|
||||||
colContent: 'Content',
|
colContent: 'Content',
|
||||||
|
colCache: 'Cache hit',
|
||||||
},
|
},
|
||||||
|
|
||||||
users: {
|
users: {
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ export default {
|
|||||||
colFailRate: '失败率',
|
colFailRate: '失败率',
|
||||||
colModels: '模型数',
|
colModels: '模型数',
|
||||||
colContent: '内容',
|
colContent: '内容',
|
||||||
|
colCache: '缓存命中',
|
||||||
},
|
},
|
||||||
|
|
||||||
users: {
|
users: {
|
||||||
|
|||||||
@@ -62,6 +62,16 @@
|
|||||||
<el-table-column :label="t('calllogs.colLatency')" width="92">
|
<el-table-column :label="t('calllogs.colLatency')" width="92">
|
||||||
<template #default="{ row }">{{ row.latency_ms != null ? row.latency_ms + 'ms' : '—' }}</template>
|
<template #default="{ row }">{{ row.latency_ms != null ? row.latency_ms + 'ms' : '—' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<!-- 2026-10-23:缓存命中量与命中率(cached ÷ prompt) -->
|
||||||
|
<el-table-column :label="t('calllogs.colCache')" width="118">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span v-if="row.tok_prompt" :class="hitCls(row)">
|
||||||
|
{{ fmtTok(row.tok_cached) }}
|
||||||
|
<i class="hit-pct">{{ hitRate(row) }}%</i>
|
||||||
|
</span>
|
||||||
|
<span v-else class="muted-t">—</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column :label="t('calllogs.colStatus')" width="84">
|
<el-table-column :label="t('calllogs.colStatus')" width="84">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span :class="row.ok ? 'ok-t' : 'err-t'">{{ row.status ?? '—' }}</span>
|
<span :class="row.ok ? 'ok-t' : 'err-t'">{{ row.status ?? '—' }}</span>
|
||||||
@@ -272,6 +282,24 @@ async function exportCsv() {
|
|||||||
setTimeout(() => URL.revokeObjectURL(href), 10_000)
|
setTimeout(() => URL.revokeObjectURL(href), 10_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 缓存命中量:≥1000 用 k 缩写,便于表格窄列显示。 */
|
||||||
|
function fmtTok(n: any): string {
|
||||||
|
const v = Number(n) || 0
|
||||||
|
if (v >= 1_000_000) return (v / 1_000_000).toFixed(1) + 'M'
|
||||||
|
if (v >= 1000) return (v / 1000).toFixed(1) + 'k'
|
||||||
|
return String(v)
|
||||||
|
}
|
||||||
|
/** 命中率 = tok_cached ÷ tok_prompt(0 保护)。 */
|
||||||
|
function hitRate(row: any): number {
|
||||||
|
const p = Number(row.tok_prompt) || 0
|
||||||
|
const c = Number(row.tok_cached) || 0
|
||||||
|
return p > 0 ? Math.round((c / p) * 1000) / 10 : 0
|
||||||
|
}
|
||||||
|
function hitCls(row: any): string {
|
||||||
|
const r = hitRate(row)
|
||||||
|
return r >= 50 ? 'hit-good' : r > 0 ? 'hit-mid' : 'hit-none'
|
||||||
|
}
|
||||||
|
|
||||||
function rowCls({ row }: { row: any }) {
|
function rowCls({ row }: { row: any }) {
|
||||||
return row.ok ? '' : 'row-fail'
|
return row.ok ? '' : 'row-fail'
|
||||||
}
|
}
|
||||||
@@ -301,6 +329,10 @@ onMounted(loadPage)
|
|||||||
.pager-bar { display: flex; justify-content: flex-end; padding-top: 10px; }
|
.pager-bar { display: flex; justify-content: flex-end; padding-top: 10px; }
|
||||||
.sub { font-size: 11.5px; color: var(--muted-2); }
|
.sub { font-size: 11.5px; color: var(--muted-2); }
|
||||||
.muted-t { color: var(--muted-2); }
|
.muted-t { color: var(--muted-2); }
|
||||||
|
.hit-pct { font-style: normal; opacity: .75; font-size: 11px; margin-left: 3px; }
|
||||||
|
.hit-good { color: var(--ok); font-variant-numeric: tabular-nums; }
|
||||||
|
.hit-mid { color: #a97c00; font-variant-numeric: tabular-nums; }
|
||||||
|
.hit-none { color: var(--muted-2); font-variant-numeric: tabular-nums; }
|
||||||
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; font-size: 12.5px; }
|
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; font-size: 12.5px; }
|
||||||
.kv span { display: flex; gap: 6px; align-items: baseline; overflow: hidden; }
|
.kv span { display: flex; gap: 6px; align-items: baseline; overflow: hidden; }
|
||||||
.kv i { font-style: normal; color: var(--muted-2); min-width: 52px; }
|
.kv i { font-style: normal; color: var(--muted-2); min-width: 52px; }
|
||||||
|
|||||||
Reference in new issue
Block a user