Skip to content

fix(openai): avoid duplicate spans after auto-instrumentation - #880

Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi/fix-openai-double-tracing-45f8a215
Oct 5, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi/fix-openai-double-tracing-45f8a215

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

Summary

  • Match wrap_openai()'s class-method check against the setup patchers applied by auto_instrument().
  • Extend the OpenAI subprocess test with a cassette-backed responses.create call that asserts one span and one set of token metrics when both entry points are used.

Closes #878.

Validation

  • mise exec -- nox -R -s 'test_openai(latest)' 'test_openai(1.92.0)' 'test_openai(1.77.0)' 'test_openai(1.71.0)' -- --vcr-record=none
  • mise exec -- nox -s test_openai_ddtrace
  • Ruff checks and pre-commit hooks

Recognize the matching class-level setup patcher markers when wrap_openai checks whether a resource is already instrumented. Cover the combined path with a replayed Responses call and assert one span with one set of token metrics.

Closes #878
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T22:24:02.844732Z d36d36f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 3aa0a56 into main Oct 5, 2026
83 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/fix-openai-double-tracing-45f8a215 branch October 5, 2026 22:34
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.

Combining auto_instrument() and wrap_openai() seems to record each OpenAI call twice

1 participant