Commit 7e59ab9
committed
prepare-sync: clear active-span ContextVar after detach
PR-C.3 review fixup. The cleared spec lifecycle reasoning at
the coord thread covered only the happy path: "ContextVar gets
overwritten on the next prepare_sync." If a subsequent
prepare_sync raises or early-returns without publishing — for
any reason — the engine reads the previous node's span and
attaches it around the new node's body, producing wrong log
correlation.
Bound the "ContextVar is set" window to the node-body scope by
clearing it to None in innermost's finally right after the OTel
detach (both _step_function_node's and _step_fan_out_node's
paths). Between dispatches and during merge / completed-event
dispatch the ContextVar is now None, so a failing or
early-returning prepare_sync can't reveal a stale span when the
engine reads. Lifecycle ownership stays with the attach/detach
scope rather than fanning out across observers in _dispatch.
Updated current_active_observer_span's docstring to reflect the
narrower lifecycle.1 parent 21e1fc7 commit 7e59ab9
2 files changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
744 | 745 | | |
745 | 746 | | |
746 | 747 | | |
747 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
748 | 753 | | |
749 | 754 | | |
750 | 755 | | |
| |||
763 | 768 | | |
764 | 769 | | |
765 | 770 | | |
| 771 | + | |
766 | 772 | | |
767 | 773 | | |
768 | 774 | | |
| |||
1112 | 1118 | | |
1113 | 1119 | | |
1114 | 1120 | | |
1115 | | - | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
1116 | 1125 | | |
1117 | 1126 | | |
1118 | 1127 | | |
| |||
1149 | 1158 | | |
1150 | 1159 | | |
1151 | 1160 | | |
| 1161 | + | |
1152 | 1162 | | |
1153 | 1163 | | |
1154 | 1164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
333 | 340 | | |
334 | 341 | | |
335 | 342 | | |
| |||
0 commit comments