cog
98f6ad21 - fix(coglet): propagate metric scope to async event loop thread (#2902)

Commit
102 days ago
fix(coglet): propagate metric scope to async event loop thread (#2902) Async predictions with concurrency > 1 silently dropped metrics recorded via current_scope().record_metric(). Two root causes: 1. _ctx_wrapper only propagated the log ContextVar to the event loop thread, not the metric scope ContextVar. Coroutines couldn't find the active scope. 2. py_current_scope() checked the process-wide SYNC_SCOPE mutex first. Under concurrency this returns whichever scope was last entered by any worker thread -- the wrong one. The fix extends _ctx_wrapper to also set the metric scope ContextVar, swaps the lookup order in py_current_scope() to prefer the ContextVar (correct per-coroutine/per-thread), and extracts the shared wrapping logic into submit_async_coroutine(). Closes #2901
Author
Parents
Loading