sangkyoonnam opened a new pull request, #941: URL: https://github.com/apache/burr/pull/941
With `use_otel_tracing=True`, a span opened inside an action on a worker thread that only attaches the OTel context is never logged to the Burr tracker, and its entry stays in the module-level `span_map` for the life of the process. `BurrTrackingSpanProcessor` looks up the tracker through the `tracker_context` ContextVar. `ThreadPoolExecutor` doesn't copy context vars, so a worker that only attaches the OTel context sees no tracker. `on_start` still caches the span, but `on_end` only logs and uncaches it when a tracker is present. The same happens to a span that ends after `post_run_step`, which clears the context var. Repro: an action that runs one child span in a `ThreadPoolExecutor` worker with `context.attach(ctx)`, stepped 50 times with the local tracker. On main, `len(span_map)` is 50 and the log has 0 `begin_span` and 0 `attribute` records. Without the thread, or with this change, it's 0, 50 and 50. Plain synchronous `MapStates` doesn't reproduce this, since each sub-application sets the context var in its executor thread, but a worker inside a child action still does. ## Changes - `FullSpanContext` carries the tracker that started the action span. When `tracker_context` is unset, a child span takes its parent's tracker. This covers the "track a map of span ID -> tracker" TODO for the unset case. - The processor still uses `tracker_context` when it's set, so tracker selection doesn't change there. - `on_end` removes the cache entry before calling the tracker, so a missing tracker or a failing tracker call can't leave it behind. ## How I tested this - Three new tests with a local `TracerProvider`: a child span on a worker thread, a span that ends after `post_run_step`, and a tracker whose `post_end_span` raises. The existing none-tracker `on_end` test now also asserts the entry is removed. All four fail on main and pass here. - `pytest tests --ignore=tests/integrations/persisters --ignore=tests/integrations/test_bip0042_bedrock.py`: 660 passed, 2 skipped. - `pre-commit run` on both files passes. ## Notes - Not covered: if `pre_start_span` raises in `on_start`, the entry still stays in `span_map`, as on main, and it now also holds the tracker. - I wrote this with Claude Code and reviewed and ran it myself. ## Checklist - [x] PR has an informative and human-readable title (this will be pulled into the release notes) - [x] Changes are limited to a single goal (no scope creep) - [x] Code passed the pre-commit check & code is left cleaner/nicer than when first encountered. - [x] Any _change_ in functionality is tested - [ ] New functions are documented (with a description, list of inputs, and expected output) - [x] Placeholder code is flagged / future TODOs are captured in comments - [ ] Project documentation has been updated if adding/changing functionality. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
