You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Gradient and pydo streaming spans vanish on close, drop, or failure #1806
The Gradient and pydo stream wrappers finalize the span only from StopIteration / StopAsyncIteration:
close() falls through __getattr__ to the wrapped SDK stream, so the span never ends;
a wrapper released after a bare for / async for loop with break has no __del__;
an exception raised while iterating is re-raised without being recorded, and nothing ends the span.
On main, the only finalize call in sdk/python/src/openlit/instrumentation/gradient/gradient.py and sdk/python/src/openlit/instrumentation/pydo/pydo.py is inside except StopIteration; __exit__ forwards to the wrapped stream and then calls _finalize(). The async twins (async_gradient.py, async_pydo.py) have the same shape. None of the four classes defines close() or __del__.
Measured locally against each wrapper with a fake stream (no credentials needed):
close() after one chunk: zero spans exported;
break out of a bare for and release the wrapper: zero spans exported;
RuntimeError from the stream after one chunk: zero spans exported;
consuming the stream to the end: one span, as expected.
Expected
Closing, dropping, or failing a stream should export the span once, keep the partial output already received, and use a finish reason that distinguishes a cut-short stream (incomplete) from a failure (error).
changed the title [-]Bug: Gradient streaming spans are never exported on close, drop, or failure[/-][+]Bug: Gradient and pydo streaming spans vanish on close, drop, or failure[/+]on Oct 20, 2026
Activity
[-]Bug: Gradient streaming spans are never exported on close, drop, or failure[/-][+]Bug: Gradient and pydo streaming spans vanish on close, drop, or failure[/+]