feat: 指标统计(执行时长/成功率/复审通过率/重试率/额度估算)tsk_lDx6zd-EbA00
从 runs/tasks/events 聚合健康度与成本指标,看板新增指标小面板。 - Store.metrics(projectId?):执行时长(avg/p50/p95,未结束与负时长不计)、 executor 成功率、复审/安全 verdict 通过率、failed→queued 重试率 + needs_attention、按模型额度粗估(时长×档位权重,标注估算) - src/model/metrics.ts:类型 + 纯函数(percentile/ratio/estimateCostUnits/emptyMetrics) - API:GET /api/metrics?project= - web:归档区上方指标面板(数字卡 + 按模型分布),失败/空数据静默隐藏 - test/metrics.test.ts:9 个用例(纯函数/空数据/时长/成功率/复审/重试/按模型/项目过滤) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -147,6 +147,13 @@ export function buildServer(opts: ApiOptions): FastifyInstance {
|
||||
return store.nextExecutable(id) ?? { next: null };
|
||||
});
|
||||
|
||||
// ---------- Metrics(健康度 + 成本聚合)----------
|
||||
// GET /api/metrics?project=<id>;不带 project = 全部项目聚合。
|
||||
app.get('/api/metrics', (req) => {
|
||||
const q = req.query as { project?: string };
|
||||
return store.metrics(q.project && q.project.trim() ? q.project.trim() : undefined);
|
||||
});
|
||||
|
||||
// ---------- Tasks ----------
|
||||
app.post('/api/projects/:id/tasks', (req) => {
|
||||
const { id } = req.params as { id: string };
|
||||
|
||||
Reference in New Issue
Block a user