Skip to content

feat(openai): Add gen_ai.request.reasoning.level to OpenAI spans#6892

Merged
pabloDeputter merged 6 commits into
masterfrom
pablo/genai-request-reasoning-level
Jul 27, 2026
Merged

feat(openai): Add gen_ai.request.reasoning.level to OpenAI spans#6892
pabloDeputter merged 6 commits into
masterfrom
pablo/genai-request-reasoning-level

Conversation

@pabloDeputter

@pabloDeputter pabloDeputter commented Jul 27, 2026

Copy link
Copy Markdown
Member

Description

Add gen_ai.request.reasoning.level to OpenAI spans for:

  • Responses API via reasoning.effort
  • Chat Completions API via reasoning_effort

Issues

Refs: #6877 & #6878; PY-2620 & PY-2621

Reminders

…s Api

Read `effort` field from the `reasoning`request parameter from `responses.create()` and set it on the gen_ai span as `gen_ai.request.reasoning_level`. `reasoning`may be passed as a dict or as the SDK's `Reasoning`object.

Refs #6878
Refs PY-2621
…ons Api

Read `reasoning_effort` request parameter from `chat.completions.create()` and set it on the gen_ai span as `gen_ai.request.reasoning_level`.

Refs #6877
Refs PY-2620
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

98651 passed | ⏭️ 6806 skipped | Total: 105457 | Pass Rate: 93.55% | Execution Time: 360m 11s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +564
Passed Tests 📈 +373
Failed Tests 📉 -1
Skipped Tests 📈 +192

➖ Removed Tests (1)

View removed tests
  • test_circular_references_span_streaming
    • File: tests.tracing.test_misc

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2508 uncovered lines.
✅ Project coverage is 89.72%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.69%    89.72%    +0.03%
==========================================
  Files          193       193         —
  Lines        24437     24402       -35
  Branches      8660      8648       -12
==========================================
+ Hits         21919     21894       -25
- Misses        2518      2508       -10
- Partials      1398      1400        +2

Generated by Codecov Action

@pabloDeputter
pabloDeputter marked this pull request as ready for review July 27, 2026 11:56
@pabloDeputter
pabloDeputter requested a review from a team as a code owner July 27, 2026 11:56
Comment thread sentry_sdk/consts.py Outdated

@alexander-alderman-webb alexander-alderman-webb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you also co-locate assertions with assertions on other request configuration such asgen_ai.request.top_p, gen_ai.request.temperature, etc ...

That way, we ensure that the attribute is set in all scenarios we test against, such as streaming and non-streaming, sync and async, etc ...

Comment thread sentry_sdk/integrations/openai.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 2 potential issues.

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 a509b01. Configure here.

Comment thread tests/integrations/openai/test_openai.py Outdated
Comment thread sentry_sdk/integrations/openai.py

@alexander-alderman-webb alexander-alderman-webb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, LGTM!

Comment thread sentry_sdk/integrations/openai.py
@alexander-alderman-webb

Copy link
Copy Markdown
Contributor

As discussed in person, adding the assertions to existing tests is ugly because it's not available on old openai versions. Feel free to go with your original approach with adding a few new tests @pabloDeputter!

@alexander-alderman-webb

Copy link
Copy Markdown
Contributor

You can merge whenever you've passed CI since I've approved the PR already.
We trust each other to make the relevant changes and merge when we approve with a comment

@pabloDeputter
pabloDeputter merged commit 54f77b9 into master Jul 27, 2026
523 of 529 checks passed
@pabloDeputter
pabloDeputter deleted the pablo/genai-request-reasoning-level branch July 27, 2026 14:14
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