Repository navigation
feat(observability): 接入 Prometheus 指标与 OpenTelemetry/Tempo 链路 - #360
Merged
gac0812 merged 12 commits intoAug 27, 2026
Merged
Conversation
HTTP/WebSocket/Agent/外部 SDK 只打点和打 span,方便定位一轮对话卡在 ASR、LLM 还是 TTS;Grafana 只负责把数据画出来。
Grafana 需要当前卡在 ASR/LLM/TTS 的人数,以及 UI 挂断、超时、道别的区分;session_id 只留进程内,不进 Prometheus label。
6 tasks
Contributor
Author
|
已补上服务端会话数据埋点(占用阶段 Gauge + 挂断原因 打断行为拆到后续草稿 PR,不放在本 PR。 |
Grafana 按登录页账号筛 turn/tool 轨迹;username 只作为 span 属性,不进 Prometheus label。
gac0812
marked this pull request as ready for review
August 26, 2026 08:01
此前整棵 /observability/ 被 ignore,登录账号筛选只留在本机 Grafana。把看板 JSON 纳入仓库,Tempo 表选出 timeflow.username。
Contributor
There was a problem hiding this comment.
Reviewed the complete observability diff, including HTTP/WebSocket lifecycle, agent/provider instrumentation, database hooks, settings, and the new tests. The implementation is generally cohesive, but the username enrichment path can make otherwise successful voice turns fail when the database is temporarily unavailable. python3 -m compileall -q backend/src backend/tests and git diff --check pass; backend/scripts/check.sh could not run because uv is not installed in the review environment.
合入 main 后该行超长,CI 的 ruff format --check 失败。
mypy 将 Protocol 标注视为对外类型,导致 composition root 无法调用 bind_username_lookup。
覆盖 composition root 的账户查找、NoOp 占用接口,以及握手/播放/数据库监听的边界分支,把 patch 覆盖率抬过 Codecov 门槛。
数据库短暂不可用时记录脱敏诊断,span 使用 unknown 且不写入缓存,恢复后下一轮仍可补上登录名。
配置改为容器路径和 Docker 服务名,去掉本机绝对路径,便于和 API 一起上云。
znnnnnnn-wil
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /metrics供 Prometheus scrape;配置TIMEFLOW_OTEL_EXPORTER_OTLP_ENDPOINT后才导出 trace,未配置则 tracing 关闭。Closes #358
Test plan
GET /metrics返回 Prometheus text,且不把/metrics自己算进业务 HTTP QPSvoice.turn以及嵌套的 tool / ASR / LLM / TTS / DB span,不必等 WebSocket 断开Verification
cd backend bash scripts/check.sh本地结果:
1090 passed, 49 skipped,coverage96.73%(门槛 95%)。覆盖要点:
/metrics不计入业务 QPSvoice.turn单独成 trace,工具 span 保持调用顺序other;失败 turn 标记 ERROR.env有 Tempo 地址时仍能断言 OTLP 开关效果对照
Grafana 把 Prometheus / Tempo 画出来即可,截图不进源码树:
Overview + HTTP
WebSocket + Voice / tools
External / database
Traces(Tempo)
单轮
voice.turn瀑布图