Skip to content

🔥 Cleancode: Remove legacy model stats columns from resource management - #4554

Merged
jeffwu-1999 merged 3 commits into
developfrom
fix/model-monitoring-stats-match
Dec 4, 2026
Merged

jeffwu-1999 merged 3 commits into
developfrom
fix/model-monitoring-stats-match

Conversation

@jeffwu-1999

@jeffwu-1999 jeffwu-1999 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

背景

资源管理页「模型」Tab 的 6 个统计列(请求数/错误率/平均耗时/平均首Token时间/Token数/Token生成速率)读取 model_monitoring_record_t 聚合数据。新的 outlet/profile 调用路径(LegacyChatModel + core/model_service)只写 OPS 监控 fact store(ES),不再写这张 PG 表,导致迁移到 profile 的模型统计恒显示 --。

本地环境实测:全部 6 个有效模型配置均为 profile 路径,model_monitoring_record_t 0 条记录,而 ES monitoring-facts-* 有 31 条 model fact(含当天流量)——资源管理页整页 --。

这些指标已由新运维看板(OPS 仪表盘 /api/ops/v1/monitoring/*)完整覆盖,产品决策:下线资源管理页的旧统计展示,指标统一由运维看板承接。

改动内容(纯前端,5 文件 +195/−285)

文件 改动
frontend/app/[locale]/resource-manage/components/resources/ModelList.tsx 删除 6 个统计列、时间范围切换(24h/7d/30d)、统计刷新按钮、三级名称匹配 join 逻辑(monitoringById/ByDisplayName/ByName + unifiedData);保留名称/类型/状态/来源列、连通性检测/编辑/删除操作、分页、添加模型按钮、容量覆盖告警 Widget;manage 与 readOnly 两种模式均正常
frontend/hooks/useMonitoringData.ts 删除(ModelList 是唯一调用方)
frontend/services/monitoringService.ts 删除 fetchModels 及仅被其使用的 buildQueryString;保留 fetchStatus(TopNavbar/useAccountMonitoring 在用)
frontend/types/monitoring.ts 删除仅被上述代码引用的 ModelMonitoringItem/MonitoringFilter;保留 MonitoringStatus
frontend/tests/component/resourceModelListStats.test.tsx 新增 2 例回归测试

后端 /monitoring/models 端点与 API_ENDPOINTS.monitoring.models 常量保留不动,不破坏可能存在的外部消费方契约;不改 SDK、不改 SQL。

测试

  • 新增组件测试 2 例:①管理列/行内容/分页/添加按钮/容量 Widget 仍在,6 个统计列头与时间范围/刷新按钮不存在,fetchModels spy 与全局 fetch 均无 /monitoring/models 请求,连通性检测仍可调服务并 refetch;②readOnly 模式无管理按钮、每行仅连通性按钮、统计列不存在
  • vitest:resourceModelListStats(2) + modelMonitoring(5) + accountMonitoring(8) + ModelList 消费方相关 tenantDeleteFeedback/casResourceIdentity/shareAuthenticationLayout(17) = 32 passed / 0 failed
  • npx tsc --noEmit 全量 0 错误
  • 版权头校验(scripts/check_copyright.py)4 个改动文件全部通过
  • 本地部署实测:新 web 镜像产物中统计列代码已移除,页面正常渲染

before:
img_v3_02181_454bae4e-2e6c-4275-b20a-d1e9c473cf4g

after:
image

正式资产(D1-D5)评估

test-e2e 中 monitoring 相关 Case 全部针对新运维看板 /api/ops/v1/monitoring/*,与本次下线的旧 /monitoring/models 前端展示无交集,无需改动正式资产。

已知遗留(无害)

  • zh/en common.json 中 6 个 monitoring.table.* 文案键成为孤儿键(应用代码已无引用),可后续清理
  • 后端 PG 统计写入链路保留(embedding 等非 profile 路径仍写入)

🤖 本 PR 由 WorkBuddy 编排 Claude Code 完成编码,WorkBuddy 独立复核 diff 与测试。

The per-model request/error/duration/token columns on the resource
management Models tab read model_monitoring_record_t, which the new
outlet/profile invocation path no longer writes, so every migrated
model showed '--'. The ops dashboard already covers these metrics
from the monitoring fact store.

- Drop the six stats columns, time-range switch and stats refresh
  button from ModelList; keep management columns, actions, pagination
  and the capacity-coverage widget in both manage and readOnly modes
- Remove the now-unused useMonitoringData hook, fetchModels service
  method and ModelMonitoringItem/MonitoringFilter types
- Keep the /monitoring/models backend endpoint untouched for any
  external consumers
- Add component tests asserting stats UI is gone, no stats request
  is issued, and management/readOnly behavior is preserved
… UI keys

Follow-up to the resource-management stats UI removal: drop the now
unconsumed consumer-side code while keeping the monitoring record
write path (SDK instrumentation, buffer, infrastructure writer) and
the /monitoring/status endpoint intact.

- Remove list_models_endpoint, the metrics aggregation query and the
  time-range helper from the management monitoring API
- Drop the /api/monitoring/models gateway exposure row (registry
  regenerated, 644 rows) and the frontend API constant
- Delete 12 orphaned monitoring.* i18n keys in zh/en locales
- Update backend tests: retire old endpoint cases, add regression
  asserting the route is unregistered and returns 404
- Update e2e assets for the retirement: API-158/F-154 now cover the
  status contract, UT-BE-022 proves provider/dashboard-role
  normalization; no formal Case deleted
- OPS dashboard endpoints (/api/ops/v1/*, /nb/v1/*) untouched
@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jeffwu-1999
jeffwu-1999 merged commit aa1f08b into develop Dec 4, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants