Record request IDs on axum request spans
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust
- 领域
- backend, observability
调研方向
从 RedactedMakeSpan 及其在 packages/axum-server/src/request_log.rs:126-134,247-270 中已有的 span 测试开始;issue 给出了失败行为和预期断言。运行 span 测试,然后扩展测试,加入已知的请求 ID 和 span 内的事件,同时保留 URI 脱敏检查。测试确认 span 包含该 ID,并且同类请求日志复查记录在 manual-verification-evidence.md 中后,即完成。
由索引模型根据 Issue 内容生成。
描述
Bug
The HTTP tracker, REST API, and health-check API each use RedactedMakeSpan for their request trace and call span.record("request_id", request_id) in both request and response hooks (packages/axum-http-server/src/v1/routes.rs:83, packages/axum-http-server/src/v1/routes.rs:94, packages/axum-http-server/src/v1/routes.rs:116; packages/axum-rest-api-server/src/routes.rs:77, packages/axum-rest-api-server/src/routes.rs:88, packages/axum-rest-api-server/src/routes.rs:110; packages/axum-health-check-api-server/src/server.rs:152, packages/axum-health-check-api-server/src/server.rs:163, packages/axum-health-check-api-server/src/server.rs:178).
The request span declares only method, redacted uri, and version; it does not declare request_id (packages/axum-server/src/request_log.rs:126-134). tracing::Span::record cannot add a field absent from the span's metadata, so these six calls have no effect on the span. Request and response events include their own request_id field, but other events cannot be correlated by request ID through the span context (packages/axum-http-server/src/v1/routes.rs:96-105, packages/axum-http-server/src/v1/routes.rs:118-139; packages/axum-rest-api-server/src/routes.rs:90-99, packages/axum-rest-api-server/src/routes.rs:112-133; packages/axum-health-check-api-server/src/server.rs:165-167, packages/axum-health-check-api-server/src/server.rs:180-187).
The span.record calls first appeared in 97233f57a (2024-12-23), when the request trace still used DefaultMakeSpan; 8cfc07be4 (2026-11-24) introduced the current RedactedMakeSpan without declaring request_id. The UDP handler shows the intended pattern: #[instrument(fields(request_id), ...)] declares the field before Span::current().record("request_id", ...) (packages/udp-server/src/handlers/mod.rs:80, packages/udp-server/src/handlers/mod.rs:89-92).
Expected behavior
An HTTP tracker, REST API, or health-check API request span should carry the same request ID that its hooks read from x-request-id, so an event emitted inside the span can be correlated with the request and response events by that ID (packages/axum-http-server/src/v1/routes.rs:88-103, packages/axum-rest-api-server/src/routes.rs:82-97, packages/axum-health-check-api-server/src/server.rs:157-167).
Bug-Fix Process
Reproduce with a request bearing a known x-request-id and capture a log event emitted inside its request span; record the initial log, runtime, and command in issue-local manual-verification-evidence.md. Add a failing regression test, declare request_id = tracing::field::Empty in RedactedMakeSpan, then rerun the test and the same request and record the final log (packages/axum-server/src/request_log.rs:126-134). Follow .claude/skills/fix-bug/SKILL.md for the red test and like-for-like recheck.
Regression Test Strategy
Extend the span test at the shared builder seam: create a request with a known ID, record it on the resulting span, emit an event inside it, and assert the captured span contains that ID. The existing test already captures an event inside RedactedMakeSpan and checks its redacted URI (packages/axum-server/src/request_log.rs:247-270). Prove the new assertion fails before the fix and passes after it; preserve the existing URI redaction assertions.
Acceptance criteria
-
RedactedMakeSpandeclares a recordablerequest_idfield while retaining the redacted URI (packages/axum-server/src/request_log.rs:126-134). - A regression test fails on the current implementation and then shows the known ID on the request span after the fix, with the URI redaction assertions still passing (
packages/axum-server/src/request_log.rs:247-270). - A like-for-like request log recheck shows the ID on the request span; record the initial and final logs in issue-local
manual-verification-evidence.md.
Related context
#3000 considers including a request ID in client error text and requires server-side error events to carry it; reliable span-level request IDs would support correlating those events with a request (docs/issues/open/3000-2993-si-b-client-error-text-policy/ISSUE.md:66-75).
- 主要语言
- Rust
- 星标
- 532
- 派生
- 56
- 平均合并
- 11 小时 20 分钟
- 30 天内合并 PR
- 282
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
torrust/torrust-tracker 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
torrust/torrust-tracker#3069 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
torrust/torrust-tracker#3058 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
torrust/torrust-tracker#2978 ·
维护者通常 1 天内回复
-
Bug
难度 2/5 1-3 小时 新手友好度 73/100
torrust/torrust-tracker#2332 ·
维护者通常 1 天内回复
-
task
难度 5/5 一周以上 新手友好度 35/100
torrust/torrust-tracker#3073 ·
维护者通常 1 天内回复
查看 torrust/torrust-tracker 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
marketing
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
difficulty: easy docs help wanted tooling
难度 2/5 1-3 小时 新手友好度 83/100
-
bug help wanted ui
难度 2/5 1-3 小时 新手友好度 85/100
userFRM/egui-charts#4386 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
eliasstravik/herdr-projects#1605 · 1 条评论 ·