Trace dump and restore at the pool API boundary

Merged
ST
11d ago
+1047-106

Summary

Record dump and restore from the pool API entry point through the reply. A dump keeps its span across worker replacement and reports success, error, or cancellation. Dump failures include bounded error text. The restore API span records the fixed error status restore failed.

Python and Node use the same caller-context capture for feeds and snapshot calls. Resume calls continue the existing execution and suspension spans. The restore API span ends when the call returns. Its child load span carries any restored execution and callbacks across suspensions.

Validation

  • Rust pool tests, including the first suspended restore and the trace parent forwarded to its peer. The pool also builds without telemetry.
  • Python telemetry and async session tests and Node telemetry tests.
  • An earlier protocol 8 staging build verified the app, SDK, and hosted worker span parents.

Summary by cubic

Records dump and restore snapshot spans at the pool API boundary, so their duration covers initial session configuration and the relay's durable acknowledgement. The spans parent from the app context active at the call and carry through worker replacement, so a retried dump still reports on the original operation. restore closes when the call returns even if the restored execution suspends; its child load span stays open across suspensions and parents their callback spans.

  • Moves snapshot span ownership from the worker's turn recorder to a shared SnapshotSpan guard that rides the turn and records the outcome on drop; Python and Node snapshot APIs capture the active app span as the parent.
  • Removes the worker-side Dump span and its per-turn attributes; restore errors report a generic message so host paths and payload details stay out of the status. Spans report success, error, or cancellation; errors carry a 64KB-capped status message and worker exception logs stay children of the snapshot span.
  • Monty records only monty.* outcome and truncation attributes; the configured provider owns vendor-specific metadata such as logfire.level_num. Raw forwarding turns create no snapshot span, and monty.turn.duration and monty.snapshot.bytes metrics are unchanged.
  • Adds integration tests covering acknowledged, raw, refused, fatal, and cancelled dumps and restores, including trace parenting, retry errors, and provider-owned metadata.