mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(telemetry): implement request tracing identifier
Introduce a middleware layer to attach a unique identifier to each HTTP request for observability purposes. The identifier is propagated via the X-Request-ID header, allowing for correlation of logs and events across distributed system components.
This commit is contained in:
18
README.md
18
README.md
@@ -76,12 +76,13 @@ docker run -p 8080:8080 --env-file .env ez-api
|
||||
|
||||
### 本地联合开发(配合 balancer)
|
||||
|
||||
- 目录结构建议:`/workspace/` 下并列放置 `ez-api` 与 `balancer`。
|
||||
- 初始化/更新 Go 工作区(Go 1.20+):在 `/workspace` 执行
|
||||
- 目录结构建议:`/workspace/` 下并列放置 `ez-api`、`balancer`、`foundation`。
|
||||
- 初始化本地 Go 工作区(Go 1.20+,不要求提交到任一仓库):在 `/workspace` 执行
|
||||
```bash
|
||||
go work use ./ez-api ./ez-api/test ./balancer
|
||||
go work init
|
||||
go work use ./ez-api ./balancer ./foundation
|
||||
```
|
||||
仓库已附带 `go.work`,若路径一致可直接复用;若放在其他位置请按上面命令重建。
|
||||
如果你只使用已发布的 `github.com/ez-api/foundation vX.Y.Z`,则不需要 `go.work`。
|
||||
|
||||
### 集成测试
|
||||
|
||||
@@ -97,12 +98,17 @@ cd ez-api
|
||||
## 日志
|
||||
|
||||
- 业务代码统一使用标准库 `log/slog`(`logger.Info("msg", "k", v)` 风格)。
|
||||
- 输出后端仍为 [zerolog](https://github.com/rs/zerolog)(通过 `internal/logging` 的 slog handler bridge),默认 ConsoleWriter。
|
||||
- 输出后端仍为 [zerolog](https://github.com/rs/zerolog)(通过 `github.com/ez-api/foundation/logging` 的 slog handler bridge),默认 ConsoleWriter。
|
||||
- 通过 `EZ_LOG_LEVEL` 控制控制平面的日志等级,配合异步 DB 写入(LogWriter)一起使用。
|
||||
|
||||
## JSON
|
||||
|
||||
- 项目内 JSON 编解码统一走 `ez-api/internal/jsoncodec`(内部使用 Sonic)。
|
||||
- 项目内 JSON 编解码统一走 `github.com/ez-api/foundation/jsoncodec`(内部使用 Sonic)。
|
||||
|
||||
## 依赖约定
|
||||
|
||||
- Control Plane(ez-api)与 Data Plane(balancer)共享一部分“协议约定/基础设施”代码(JSON、日志、provider type 规则),统一沉淀在 `github.com/ez-api/foundation`。
|
||||
- 本仓库的 `go.mod` 需要依赖一个可用的 `foundation` 版本:发布后建议锁定到 `vX.Y.Z`;本地联调可使用 `go.work`(见下文)。
|
||||
|
||||
## 设计决策
|
||||
|
||||
|
||||
Reference in New Issue
Block a user