Skip to content

fix(openai): Only finish relevant spans in Chat Completions patches#6190

Merged
alexander-alderman-webb merged 6 commits intomasterfrom
webb/openai/remove-get-current-span-completions
May 5, 2026
Merged

fix(openai): Only finish relevant spans in Chat Completions patches#6190
alexander-alderman-webb merged 6 commits intomasterfrom
webb/openai/remove-get-current-span-completions

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

@alexander-alderman-webb alexander-alderman-webb commented May 4, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Codecov Results 📊

12 passed | Total: 12 | Pass Rate: 100% | Execution Time: 1.61s

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 15183 uncovered lines.

Files with missing lines (1)
File Patch % Lines
openai.py 4.23% ⚠️ 656 Missing

Generated by Codecov Action

@alexander-alderman-webb alexander-alderman-webb changed the title fix(openai): Only finish relevant spans in Completions patches fix(openai): Only finish relevant spans in Chat Completions patches May 4, 2026
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 4, 2026 07:04
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner May 4, 2026 07:04
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f79b635. Configure here.

Comment thread sentry_sdk/integrations/openai.py
Base automatically changed from webb/openai/separate-sync-and-async-embeddings to master May 5, 2026 14:25
@alexander-alderman-webb alexander-alderman-webb merged commit 961eee2 into master May 5, 2026
156 checks passed
@alexander-alderman-webb alexander-alderman-webb deleted the webb/openai/remove-get-current-span-completions branch May 5, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants