feat: add structured errors observability and interceptors - #11
Merged
Merged
Conversation
This was referenced Sep 14, 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.
目标
完成当前 P2 的核心工程化能力:结构化错误模型、框架内置可观测性指标、客户端/服务端拦截器链。暂不把熔断/限流塞进这一轮,避免范围失控。
1. 结构化 RPC 错误模型
扩展
rpc_meta.proto:RpcStatusCodeRpcResponse新增status_code/error_typeRpcRequest新增 metadata map兼容策略:继续保留
message="Success"/ 错误文本,旧 Python/Go protobuf 客户端会忽略新增字段;Java 客户端开始将结构化错误转换成RpcException。服务端会区分服务不存在、方法不存在、非法参数、业务异常、线程池繁忙和内部异常,不再只返回
Error: xxx字符串。2. 可观测性指标
新增轻量
RpcMetrics,不引入额外监控依赖:通过
RpcMetrics.getInstance().snapshot(...)可直接读取快照,后续可很容易适配 Micrometer / Prometheus。3. Interceptor 链
新增:
RpcInterceptorRpcInvocationContextRpcInterceptorRegistryRpcSide能力:
order()排序RpcRequest,用于 metadata / trace-id 注入4. Transport / Client 语义整理
RpcException + RpcStatusCodestatus_code但message=Success的旧响应5. 每次 CI 发布 RPC 性能快照
新增
RpcPerformanceSnapshotTest,每次 PR / main CI 都会执行:每次运行生成并上传
rpc-performance-snapshotartifact(保留 30 天):performance.json:机器可读的环境、配置、吞吐、P50/P95/P99、Client/Server metricssummary.md:直接展示在 GitHub Actions Summarylatency-samples.csv:每个请求的原始 latency sample,方便后续做趋势图和回归分析性能快照会校验 Client / Server metrics 的 total/success/failure/timeout/active 与实际请求数一致;但不会用 GitHub Hosted Runner 的绝对 QPS/延迟做硬门槛,避免 runner 抖动导致误报。JMH 继续负责更严格的微基准。
同时将客户端“每个成功响应”的 INFO 日志降为 DEBUG,避免日志 I/O 污染吞吐和延迟观测。
测试
新增覆盖:
主 CI 继续要求 Build / Unit Tests & Coverage / RPC Integration / CI Gate 全部通过。