Skip to content

[Trivial] Fix request_id span propagation#4590

Merged
fleupold merged 3 commits into
mainfrom
fix_request_id_span_propagation
Jul 3, 2026
Merged

[Trivial] Fix request_id span propagation#4590
fleupold merged 3 commits into
mainfrom
fix_request_id_span_propagation

Conversation

@fleupold

@fleupold fleupold commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Description

Follow up on #4582. During testing I noticed that request id is never populated.

Root cause is a wiring mismatch dating back to the observe restructure (#4196). make_span creates the per-request span as info_span!("http_request", ?request_id, …), but from_current_span() only captures a span named "request" with a string field "id".

Two things break the capture:

  1. the span name differs (http_request vs request), and
  2. ?request_id records the value via record_debug (but its record_debug is a no-op).

Note, that this was also breaking forwarding request ids between orderbook/autopilot -> solver calls.

Changes

  • make_span now records the id via record_str and reuses the shared SPAN_NAME
  • align SPAN_NAME with the emitted name ("request" -> "http_request")
  • add a round-trip unit test asserting a span from make_span is readable by from_current_span()

How to test

unit test +

Manual (e2e):

  1. Temporarily log the computed headers in ethrpc's annotate
  2. cargo nextest run -p e2e -E 'test(=eth_integration::local_node_eth_integration)' --run-ignored ignored-only --no-capture
  3. Grep for request_ids=:. This went from 0 (before) to 64 of 281 header lines populated; background/cached RPC calls continue to stay empty (expected).

@fleupold fleupold requested a review from a team as a code owner July 3, 2026 12:44
@claude

claude Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Claude finished @fleupold's task in 2m 2s —— View job


PR Review: Fix request_id span propagation

  • Read changed files and skill instructions
  • Analyze the diff vs origin/main
  • Check for other affected usages (span name / field rename)
  • Verify the load-bearing assumption of the fix

Verdict

LGTM. This is a correct, minimal fix and the root-cause diagnosis in the description is accurate.

Why the fix works — the entire fix hinges on request_id = request_id (a String) being recorded via record_str rather than record_debug. That holds: tracing's Value for String impl routes through record_str. This is confirmed independently by the pre-existing test request_id_from_current_span, which already relied on Stringrecord_str for the id field. The old ?request_id used the Debug adapter (record_debug, a no-op in the visitor), which is exactly why capture silently failed.

Consistency check — I searched all call sites:

  • make_span (production HTTP path) already emitted the span name http_request and field request_id, so aligning SPAN_NAME/SPAN_FIELD to those values fixes the capture without changing emitted log output. No dashboard/log-query regression beyond what was already the case.
  • The info_span() helper (old name request/field id) is only referenced from tests, so renaming it has no production impact.
  • All other from_current_span() consumers (ethrpc, driver, autopilot, solvers, price-estimation, zeroex, event_bus) are read-only and unaffected.

Test — the added make_span_is_readable_by_from_current_span round-trip test is the right guard for this class of wiring bug, since the field name in make_span must be a literal identifier and can't reference the SPAN_FIELD const.

No blocking issues, no inline comments. One optional (non-blocking) observation: info_span() is now pub but only used by tests in this crate — could be #[cfg(test)] or dropped if there's no external consumer, but that's orthogonal to this fix.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request standardizes the span name and field name used for distributed tracing across the axum integration and the request_id module, updating them to 'http_request' and 'request_id' respectively. It also adds a test to ensure that spans created by make_span can be correctly read by from_current_span. No review comments were provided, and there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aligns the span name and field used for distributed tracing request IDs across the Axum integration and the request ID module. Specifically, it updates SPAN_NAME to 'http_request', introduces SPAN_FIELD as 'request_id', and updates the span creation and recording logic to use these constants consistently. A new integration test was also added to verify that spans created by make_span are correctly readable by from_current_span. No critical issues were found, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@MartinquaXD MartinquaXD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️

@jmg-duarte jmg-duarte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great detective work 🕵️

@fleupold fleupold enabled auto-merge July 3, 2026 17:20
@fleupold fleupold added this pull request to the merge queue Jul 3, 2026
Merged via the queue into main with commit 901a7c1 Jul 3, 2026
22 checks passed
@fleupold fleupold deleted the fix_request_id_span_propagation branch July 3, 2026 17:39
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants