-
Notifications
You must be signed in to change notification settings - Fork 0
[Priority: Med] [Ops] 增加可选 Prometheus metrics export 接口 #277
Copy link
Copy link
Open
Labels
status:todoPlanned but not startedPlanned but not started
Description
🔍 发现的问题 / 原始需求描述
- 当前主干已经有一套轻量 metric log record,但仍停留在 debug 日志维度,运维系统无法直接抓取或聚合。
- 这导致容量观察、异常峰值判断、长流连接占用等信息只能靠日志二次加工,不利于长期作为 runtime 运行。
- 与本次审查建议相比,
metrics export和trace context应拆成两个 issue;本 issue 仅聚焦可选 metrics export。
🛠️ 详细实施方案
- 涉及文件:
src/opencode_a2a/config.py - 涉及文件:
src/opencode_a2a/server/application.py - 涉及文件:
src/opencode_a2a/execution/executor.py - 涉及文件:
src/opencode_a2a/execution/stream_runtime.py - 涉及文件:
docs/guide.md - 涉及文件:
tests/server/test_app_behaviors.py - 涉及文件:
tests/execution/test_metrics.py - 设计一个默认关闭的配置开关,例如
A2A_METRICS_ENABLED=true|false,在开启时暴露/metrics或等价 scrape endpoint。 - 保持现有 metric log 名称不变,只是在标准导出层复用这些信号,避免一次性重写现有回归面。
- 为长流和异步路径至少补齐:请求总数、进行中流数量、取消请求总数、上游并发拒绝次数。
- 核心逻辑 / 伪代码:
if settings.a2a_metrics_enabled:
registry.counter("a2a_stream_requests_total").inc()
registry.gauge("a2a_stream_active").add(+1/-1)
expose GET /metrics
else:
keep existing debug metric logs only
🧪 回归测试建议
- 增加
/metrics开启/关闭两种配置下的接口测试。 - 确认现有 metric log 测试不回归。
- 运行
./scripts/doctor.sh。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status:todoPlanned but not startedPlanned but not started