Skip to content

feat(openai): Set gen_ai.response.finish_reasons on chat completion spans - #8028

Open
manojmulammagari wants to merge 1 commit into
getsentry:masterfrom
manojmulammagari:feat/openai-finish-reasons
Open

manojmulammagari wants to merge 1 commit into
getsentry:masterfrom
manojmulammagari:feat/openai-finish-reasons

Conversation

@manojmulammagari

Copy link
Copy Markdown

Closes #8000
Part of #8004

Summary

  • Extracts choice.finish_reason from OpenAI Chat Completion responses (non-streaming, sync streaming, and async streaming) and sets SPANDATA.GEN_AI_RESPONSE_FINISH_REASONS (gen_ai.response.finish_reasons) as a list[str] on both Span and StreamedSpan.
  • Filters out intermediate streaming chunks where finish_reason is None and only sets the span attribute when at least one non-null finish reason is present.
  • Adds unit test assertions covering single-choice, multi-choice, sync streaming, and async streaming spans.

@manojmulammagari
manojmulammagari requested a review from a team as a code owner October 14, 2026 11:52

This branch has not been deployed

No deployments
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.

openai: Set gen_ai.response.finish_reasons

1 participant