Skip to content

Fix Temporal replay span parent propagation#560

Open
Thibault Soubeste (thibaultsoubeste) wants to merge 1 commit into
braintrustdata:mainfrom
thibaultsoubeste:fix/temporal-replay-span-parent
Open

Fix Temporal replay span parent propagation#560
Thibault Soubeste (thibaultsoubeste) wants to merge 1 commit into
braintrustdata:mainfrom
thibaultsoubeste:fix/temporal-replay-span-parent

Conversation

@thibaultsoubeste

Copy link
Copy Markdown

Fix Temporal replay parent propagation for workflows that schedule work after replay.

What was happening:

  • Workflow spans are intentionally not emitted again during replay.
  • The outbound workflow interceptor still needs the workflow span context when it injects Braintrust headers into later activity, local activity, and child workflow commands.
  • After replay, for example after worker cache eviction, newly scheduled activity spans could attach outside the temporal.workflow.<Workflow> span.

Fix:

  • Add a Temporal patch marker for the new replay-safe propagation path.
  • Use stable per-run workflow span ids keyed by Temporal namespace, workflow type, workflow id, and run id.
  • Rebuild the workflow span context during replay, and use the same rebuilt context during the original execution so the propagated Braintrust header shape stays consistent.
  • Add a regression workflow that forces replay with max_cached_workflows=0, resumes by signal, and checks post-replay activities stay under the single workflow span both with and without a client parent.

@AbhiPrasad

Copy link
Copy Markdown
Member

hey Thibault Soubeste (@thibaultsoubeste) thank you for the PR! I will review this tomorrow and work on getting it merged + released asap afterwards.

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.

2 participants