Skip to content

router: keep the caller's trace context across the resume flight detach - #1487

Merged
Tim Bai (baizhenyu) merged 1 commit into
agent-substrate:mainfrom
git286:fix-wake-trace-fragmentation
Sep 4, 2026
Merged

Tim Bai (baizhenyu) merged 1 commit into
agent-substrate:mainfrom
git286:fix-wake-trace-fragmentation

Conversation

@git286

@git286 Da Huang (git286) commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

The singleflight resume flight rebuilds its context from context.Background() so that a disconnecting caller cannot cancel the shared resume other parked requests are waiting on. That detach severed more than cancellation: it dropped the caller's span context, so the ateapi ResumeActor call started a fresh root trace, sampled independently of the ingress request. A sampled wake-on-request therefore produced a trace containing only the router's own spans, while the server-side resume work (step.*, atelet, snapshot fetch) landed in separate orphan traces — on a live install, a request that woke a suspended actor fragmented into three disconnected traces, and internal step spans showed up as trace roots.

Carry the leader's SpanContext into the flight's background context. Cancellation stays detached; only trace identity crosses the boundary. Joiners share the leader's flight, so the flight carries the leader's trace — the accepted corollary of deduplicating onto one control-plane RPC per hot actor.

Fixes #1486

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

The singleflight resume flight rebuilds its context from
context.Background() so that a disconnecting caller cannot cancel the
shared resume other parked requests are waiting on. That detach severed
more than cancellation: it dropped the caller's span context, so the
ateapi ResumeActor call started a fresh root trace, sampled independently
of the ingress request. A sampled wake-on-request therefore produced a
trace containing only the router's own spans, while the server-side
resume work (step.*, atelet, snapshot fetch) landed in separate orphan
traces — on a live install, a request that woke a suspended actor
fragmented into three disconnected traces, and internal step spans showed
up as trace roots.

Carry the leader's SpanContext into the flight's background context.
Cancellation stays detached; only trace identity crosses the boundary.
Joiners share the leader's flight, so the flight carries the leader's
trace — the accepted corollary of deduplicating onto one control-plane
RPC per hot actor.
@baizhenyu
Tim Bai (baizhenyu) merged commit 1c511d1 into agent-substrate:main Sep 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

router: wake-path resume detach drops trace context - one request fragments into three traces

3 participants