dodjdnh opened a new issue, #3835:
URL: https://github.com/apache/dubbo-go/issues/3835
### What problem would this solve?
`#3784` 已引入 `common/rpcerror`(错误来源树与 `Observation` 完成态状态机)及 `metrics/rpc` 中的
`classifyError`,但当前错误归因仍局限于 Metrics 单点,且存在多协议与链外盲区:
1. **能力锁死在单信号内**:`classifyError` 是 `metrics/rpc/error_classifier.go`
中的私有函数(且直接依赖 `triple_protocol`),`Observation` 也由 `filter/metrics` 创建并仅支持单个
`OnComplete` 回调,导致:
- `filter/otel/trace` 仅调用 `span.SetStatus(codes.Error, err.Error())`,缺少
`span.RecordError` 与统一错误分类属性;关闭 Metrics 时完全无法获取底层 `Observation` 来源。
- `filter/accesslog` 在 `invoker.Invoke` 之前写入队列,日志中缺少调用结果与错误分类字段。
- `logger/core/zap`(`recordErrorToSpan`)开启时会与 OTel Trace Filter 对同一 Span
写入异常与状态,造成重复或冲突记录。
2. **协议状态码与压缩盲区**:
- `protocol/dubbo/impl/codec.go` 在解码非 `Response_OK` 响应时丢弃了
`Header.ResponseStatus`(`30/31/40/50/60/70/80/90`),仅生成裸 `java exception:`
错误;`remoting/exchange_client.go` 也未透传 `Response.Status`。
- `protocol/triple/triple_protocol/compression.go` 在压缩/解压失败时返回未标记的
`CodeInternal` / `CodeInvalidArgument`,未标为 `rpcerror.Codec`。
3. **Filter 链外失败漏记**:`client/action.go` 将 `ReferenceFilterKey` 挂载在
`cluster.Join(...)` 内层的单实例 Invoker 上,导致路由、负载均衡与无可用节点(如 `No provider is
available`)等失败完全绕过 Metrics 与 Trace Filter。
### Expected Behavior & Proposed Solution
将错误归因抽象为全框架共享的跨信号契约,使同一次 RPC 失败在 **Metrics**、**Trace**、**Log**
中输出一致的错误分类,并补齐多协议与链外失败路径:
- **协议无关的归因契约**:抽离公共错误分类枚举、来源语义与优先级规则,通过轻量接口提取协议状态码,避免 `common/rpcerror`
与具体协议包产生循环依赖。
- **多消费者 `Observation`**:将 `Observation` 的创建与完成事件从 `filter/metrics` 解耦,使
Trace 与 Log 在异步回调或关闭 Metrics 时也能读取确认后的本地来源。
- **三信号一致消费**:
- **Metrics**:复用统一契约统计分类失败 Counter,区分逻辑失败与重试 Attempt,避免重复计数。
- **Trace**:在 `filter/otel/trace` 中调用 `span.RecordError` 并写入统一错误属性,厘清与
`ZapCtxLogger.recordErrorToSpan` 的写入边界。
- **Log / AccessLog**:在调用完成后输出与 `trace_id` 关联的结构化错误分类字段。
- **多协议与链外补全**:
- 在 Dubbo 解码与 `remoting` 返回链路中保留 `ResponseStatus` 并接入统一分类。
- 为 Triple 压缩/解压失败补标 `rpcerror.Codec`(同时保持体积超限 `CodeResourceExhausted` 归为
`Limit`)。
- 在 Cluster 出口为 Filter 链外失败(选址/路由无可用实例)接入逻辑层统一归因。
### Acceptance Criteria
- [ ] 同一次可归因的 RPC 失败在 Metrics、Trace 与 Log/AccessLog 中输出一致的错误分类。
- [ ] 无可靠来源或 `errors.Join` 分支来源冲突时安全回退至 `Unknown`,不依赖错误文本字符串匹配。
- [ ] 启用 `CtxLogger` 时 Trace Span 不出现重复的 `RecordError` 与状态覆盖。
- [ ] Dubbo `ResponseStatus`、Triple 压缩/解压失败及 Cluster 链外失败均有单元测试或集成测试覆盖。
### Related Issues
- Related to #3562, #3784, #3337, #3338
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]