fix(sdk): spawn periodic reader worker at reader build time#3605
Open
karan-vk wants to merge 2 commits into
Open
fix(sdk): spawn periodic reader worker at reader build time#3605karan-vk wants to merge 2 commits into
karan-vk wants to merge 2 commits into
Conversation
The async-runtime PeriodicReader stored its spawn closure and only ran it inside register_pipeline, so the worker task landed on whatever tokio runtime was ambient when the meter provider was built, not when the reader taking the runtime argument was built. Building the reader and provider in different contexts could deadlock or panic. Spawn the worker eagerly in build(), matching the async-runtime BatchSpanProcessor and BatchLogProcessor, and reduce ProducerOrWorker to a plain optional producer. Fixes open-telemetry#3601
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3605 +/- ##
=======================================
+ Coverage 83.2% 83.3% +0.1%
=======================================
Files 130 130
Lines 28246 28286 +40
=======================================
+ Hits 23506 23583 +77
+ Misses 4740 4703 -37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #3601
Changes
periodic_reader_with_async_runtime::PeriodicReaderstored its spawn closure and only ran it insideregister_pipeline, so the worker task landed on whatever tokio runtime was ambient when the meter provider was built rather than when the reader, which takes theruntimeargument, was built. Building the reader and the provider in different contexts could deadlock or panic.The worker is now spawned eagerly in
build(), matching the async-runtimeBatchSpanProcessorandBatchLogProcessor, andProducerOrWorkeris reduced to a plainOptionproducer. Added a regression test that builds the reader inside a runtime and the provider outside of one; it panics without this fix.Behavior note: a reader that is built but never attached to a provider now runs its interval ticker and logs collect errors, where before the worker was never spawned. This matches the existing behavior of the async-runtime batch processors.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes