Repository navigation
Backport: end the chain span when a link raises, and nest parallel storage spans under it - #234
Merged
howethomas merged 2 commits intoDec 3, 2026
Conversation
…s under it. A chain whose link raised never exited its vcon_processing span. The span stayed attached in the worker thread, so every chain that thread ran next became its child, and when garbage collection finally closed it, its status was unset. process() now holds the span in a with block. On failure the span records the exception, takes status ERROR, is detached and ended, and the exception reaches _handle_vcon, which moves the vCon to the DLQ as before. Parallel storage writes ran in pool threads, which start with an empty context, so each storage span began its own trace. Each write now runs in a copy of the caller's context and nests under the chain span. conserver/tests/test_chain_span_context.py covers the failed chain, the next chain in the same thread, the ERROR status, parallel storage, and the success path with its correlation attributes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ool threads. - The context stored for an egress list carries the chain span's trace and span ids. Moving the wrap-up outside the chain span makes it fail. - A KeyboardInterrupt or SystemExit from a link has ended and detached the chain span by the time it reaches the caller. The old manual enter and exit fails it. - The parallel storage test holds both writes in flight at once, so they run on two pool threads instead of one reused thread, and checks that. Co-Authored-By: Claude Opus 5.5 <[email protected]>
howethomas
force-pushed
the
howethomas/conserver-trace-context-prod
branch
from
December 3, 2026 03:48
164ed47 to
f6943b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #233 to the production build branch. The commit is cherry-picked from it and applied cleanly; the only nearby difference on this branch is that the "Started processing vCon" line logs at INFO, and it still does.
A failed chain's span stayed open.
process()exited thevcon_processing.<chain>span only on the success path, so after a link raised, the span stayed current in that worker thread and every later chain in the thread became its child, until the process restarted. That span ended with status unset, so failed chains could not be found by status. Parallel storage spans were roots, since pool threads start with an empty context.Change
process()holds the span in awithblock and runs the old body as_run_chain(). On failure the span records the exception, takes status ERROR, is detached and ended, and the exception reaches_handle_vcon, which moves the vCon to the DLQ as before.contextvars.copy_context(), so its span nests under the chain span.Tests
Same
conserver/tests/test_chain_span_context.pyas #233, run on this branch. Each test, with its result before the fix and after it:test_failed_chain_detaches_and_ends_its_span_before_handle_vcon_returns: a chain whose link raises leaves no current span in the thread and has ended its chain span when_handle_vconreturns. Before:span 'vcon_processing.failing_chain' is still current in the worker thread. After: passes.test_next_chain_in_the_same_thread_gets_a_root_span_in_a_new_trace: the next chain in that thread gets a root span in a new trace. Before:next chain span has parent e142416228491c2e; expected a root span. After: passes.test_failed_chain_span_is_error_with_the_exception_recorded: the failed chain span is ERROR with the exception recorded. Before:the failed chain span was never ended. After: passes.test_interrupt_from_a_link_still_ends_and_detaches_the_chain_span_on_its_way_out[KeyboardInterrupt]and[SystemExit](new): the interrupt from a link has ended and detached the chain span by the time it reaches the caller. Status is not checked. Before, on the old manual enter and exit:span 'vcon_processing.failing_chain' is still current in the worker thread, for both. After: both pass.test_egress_context_is_taken_inside_the_chain_span(new): the context stored for an egress list carries the chain span's trace id and span id. Before: passes, since the old code already ran egress inside the span. On a copy that calls the wrap-up after thewithblock:Expected 'store_context_sync' to have been called once. Called 0 times.After: passes.test_parallel_storage_spans_nest_under_the_chain_span: with parallel storage and two backends, eachstorage.*span has the chain span as parent and shares its trace. Changed: each fake write now waits on a two-party barrier, so both writes are in flight at once on two pool threads, and the test checks that. Without it the pool reused one thread for both. Before:storage.store_b is a root span. After: passes.test_successful_chain_span_is_ok_with_correlation_attributes: the success path still ends OK withvcon.uuid,tenant.idandcall.session_idon the chain span. Before: passes. After: passes.Without the fix: 6 failed, 2 passed. With it: 8 passed.
common/tests/test_otel_correlation.pystill passes.Full suite on the host with Python 3.12 and a local plain Redis: 694 passed, 20 skipped, 8 failed. The 8 failures are all in
common/tests/test_api.py: this branch's API stores vCons with RedisJSON (JSON.SET), which plain Redis does not have. The same 8 fail on the branch without this commit. They need Redis Stack, asdocker compose run --rm conserver pytestprovides.🤖 Generated with Claude Code