Skip to content

fix: inherit request IDs in child spans + preserve span in InflightGuard [DIS-1643] - #7928

Closed
nnshah1 wants to merge 1 commit into
mainfrom
nnshah1/DIS-1643-fix-span-inheritance
Closed

fix: inherit request IDs in child spans + preserve span in InflightGuard [DIS-1643]#7928
nnshah1 wants to merge 1 commit into
mainfrom
nnshah1/DIS-1643-fix-span-inheritance

Conversation

@nnshah1

@nnshah1 nnshah1 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Two fixes for request ID propagation:

  1. DistributedTraceIdLayer: Inherit x_request_id and request_id from parent span context when the child span doesn't set them. Without this, inject_trace_headers_into_map (called from child spans like completions_single) couldn't include x-request-id in transport headers, so workers never received it.

  2. InflightGuard: Capture Span::current() at creation and enter() it in Drop. For streaming responses, the http-request span closes when response headers are sent, but InflightGuard drops later when the stream ends. Without the stored span, the "request completed" log lost all span context (trace_id, x_request_id, model, etc.).

Test plan

  • cargo clippy --workspace -- -D warnings clean
  • cargo test --workspace passes (pre-existing preprocessor flake only)
  • E2e: x_request_id now appears in worker JSONL logs
  • E2e: cancellation "request completed" ERROR log now has full span context
  • CI checks pass

🤖 Generated with Claude Code

…n InflightGuard

Two fixes for request ID propagation:

1. DistributedTraceIdLayer now inherits x_request_id and request_id from
   parent spans when the child doesn't set them. This ensures
   inject_trace_headers_into_map includes x-request-id in transport
   headers even when called from child spans.

2. InflightGuard captures the current span at creation and enters it in
   Drop. This preserves span context (trace_id, x_request_id, etc.) on
   the "request completed" log even when the guard outlives the span
   (e.g. streaming responses where the guard drops after client disconnect).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nnshah1
nnshah1 requested a review from a team April 6, 2026 23:11
@github-actions github-actions Bot added fix frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` labels Apr 6, 2026
@nnshah1

nnshah1 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor Author

Moving these fixes into the test PR #7817 to keep everything together.

@nnshah1 nnshah1 closed this Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant