Skip to content

fix: prevent OpenTelemetry span leak when chat completion create()#11

Merged
frac merged 1 commit into
mainfrom
fix_finalize_bug
Mar 11, 2026
Merged

fix: prevent OpenTelemetry span leak when chat completion create()#11
frac merged 1 commit into
mainfrom
fix_finalize_bug

Conversation

@frac
Copy link
Copy Markdown
Collaborator

@frac frac commented Mar 6, 2026

Move the client.chat.completions.create() call inside the existing
try/catch/finally block so that if it rejects (e.g. auth error, network
timeout, invalid model), the span is properly ended and the error is
recorded. Previously the span would leak because the finally block
never ran.

Add regression test verifying recordException, setStatus, and end()
are called on the span when create() rejects.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 6, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

…jects

  Move the client.chat.completions.create() call inside the existing
  try/catch/finally block so that if it rejects (e.g. auth error, network
  timeout, invalid model), the span is properly ended and the error is
  recorded. Previously the span would leak because the finally block
  never ran.

  Add regression test verifying recordException, setStatus, and end()
  are called on the span when create() rejects.
@frac frac force-pushed the fix_finalize_bug branch from 25680d1 to 7200f03 Compare March 11, 2026 09:00
@frac frac merged commit bbe6841 into main Mar 11, 2026
9 checks passed
@frac frac deleted the fix_finalize_bug branch March 11, 2026 09:03
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