Record request IDs on axum request spans

オープン 初心者向け
#3,080 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

まず RedactedMakeSpan と packages/axum-server/src/request_log.rs:126-134,247-270 にある既存の span テストを確認します。issue には失敗する動作と期待されるアサーションが記載されています。span テストを実行し、URI の秘匿化チェックを維持したまま、既知のリクエスト ID と span 内のイベントを追加します。テストで span に ID が含まれることを確認し、同条件でのリクエストログの再確認を manual-verification-evidence.md に記録したら完了です。

索引モデルが issue の本文から書いたものです。

説明

Bug

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

  • RedactedMakeSpan declares a recordable request_id field 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分
マージ済み PR(30日)
282

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

torrust/torrust-tracker のほかの issue

torrust/torrust-tracker の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。