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: Go SDK OpenAI and Anthropic streaming failures end the span before recording the error #1982
OpenLIT Go SDK (sdk/go, OpenAI and Anthropic instrumentation)
What happened?
When a streaming request fails before any chunk is read (marshal error, request-creation error, transport error, or a non-200 response), the span is ended first and the error is recorded afterwards:
span.End()
helpers.RecordError(span, err)
RecordError and SetStatus on an ended span are ignored by the OpenTelemetry SDK, so the span of a failed streaming call finishes with status Unset and no exception event. This is in sdk/go/instrumentation/openai/streaming.go (the four failure paths in createChatCompletionStream) and sdk/go/instrumentation/anthropic/streaming.go (the same four paths). The vllm instrumentation in the same SDK uses the right order (helpers.RecordError(span, err) then span.End(), vllm/streaming.go).
Steps to reproduce
Point either client at an httptest server that answers the streaming request with 401, call the streaming method with an in-memory span recorder, and inspect the ended span.
Expected
Status Error and one exception event on the span, like a failed non-streaming call.
Actual
Status Unset and no events, so a failed streaming call looks like one that did not fail.
Activity