◐ Shell
clean mode source ↗

fix(openai): Only finish relevant spans in Chat Completions patches by alexander-alderman-webb · Pull Request #6190 · getsentry/sentry-python

Description

OpenAI Completions spans are only created in _new_sync_chat_completion() and _new_async_chat_completion().

Exit spans in these functions when the openai library function raises an exception.

Resolves an edge case where _new_sync_chat_completion() or _new_async_chat_completion() exits early and does not create a span and get_current_span() therefore returns a non-openai span.

Issues

Reminders