Skip to content

Bug: Gradient and pydo streaming spans vanish on close, drop, or failure #1806

Open

Description

@feiiiiii5

Component

OpenLIT Python SDK

What happened?

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).

Activity

  1. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions