Lyon
|
fb1fe8d94a
|
feat(otel): 服务端 HTTP request span 追穿 hwlab-cloud-api 503 (#1764)
问题:hwlab-cloud-api 服务端 503(如 workbench 投影存储不可用)在 Tempo
里只有 workbench-ui 浏览器侧 span,没有服务端 request handler span,导致
后端根因(error.code=projection_store_unavailable 等)只能在应用日志里看,
OTel 链路追不到服务端处理层。
修复:
- otel-trace.ts 新增 emitHttpServerRequestSpan(scope hwlab.http.server,
SPAN_KIND_SERVER),捕获 http.route/method/status_code/status_class、
request.id,5xx 时落 STATUS_CODE_ERROR 并把 error.code/category/layer
写入 span 属性与 status.message。
- error-envelope.ts 的 decorateErrorPayloadForHttp 把诊断 error code/
category/layer 回写到 hwlabHttpRequestContext.lastHttpError,供 finish
时复用,避免重复解析。
- server.ts 在 response finish 时按 http context + backend performance
时序发服务端 span;health/metrics 探针路由跳过,避免 OTel 噪声洪泛。
验收:canary 调用 emitHttpServerRequestSpan 发 503 projection_store_unavailable
span 到 D601 platform-infra OTel collector,Tempo 可查到 service=hwlab-cloud-api、
scope=hwlab.http.server、http.response.status_code=503、error.code=
projection_store_unavailable 的 ERROR span。
|
2026-06-20 20:31:36 +08:00 |
|