fix(otel): close child spans before parent contexts - #598
Conversation
Codex AI reviewNo actionable findings. Residual risk is limited to static review; tests were not executed per review constraints. Reviewed commit |
Claude AI reviewThe change is a correct, minimal, well-scoped fix. No actionable findings. Fix correctness — End-time containment — pending spans are Thread safety / compat — the registry snapshot is still taken under Test (test_invocation_plugin.py:202-246) reproduces the exact failing topology (open CONTEXT/WAIT_FOR_CALLBACK parent + open CALLBACK child at PENDING invocation end) and asserts parentage and end-time containment. No public API, serialization, or replay/determinism behavior is affected. Residual test risk: Low. The end-time containment assertion depends on wall-clock monotonicity between sequential Reviewed commit |
Summary
Root cause
InvocationOtelPlugin.on_invocation_enddrained its parent-first span registry in insertion order. For wait-for-callback invocations, this ended the parent context before its callback child, producing the 45 us and 41 us containment violations in cases 10 and 17.Failure: https://github.com/aws/aws-durable-execution-conformance-tests/actions/runs/30420590979/job/90476416155?pr=40
Verification
hatch run dev-otel:test(93 passed)hatch run test:all(3063 passed, 2 skipped)hatch run types:checkhatch fmt --check