René's URL Explorer Experiment
Title: fix(integrations): record output for with_raw_response and with_streaming_response by chrikrah · Pull Request #8039 · getsentry/sentry-python · GitHub
Open Graph Title: fix(integrations): record output for with_raw_response and with_streaming_response by chrikrah · Pull Request #8039 · getsentry/sentry-python
X Title: fix(integrations): record output for with_raw_response and with_streaming_response by chrikrah · Pull Request #8039 · getsentry/sentry-python
Description: fix(integrations): record output for with_raw_response and with_streaming_response
Description
sentry_sdk/integrations/anthropic.py:794 requires hasattr(result, "content"). A .with_raw_response wrapper has no content, so the span ends at unknown_response on line 824. openai.py:919 passes the wrapper on too, and _set_completions_api_output_data finds no choices and records nothing. Both integration docs promise Sentry "will automatically collect information about prompts, tools, tokens, and models". The Anthropic page names messages.create as the supported function. .with_raw_response and .with_streaming_response call that same create behind an X-Stainless-Raw-Response header, so the span opens and records no output.
Before:
$ python -W ignore repro.py # master 2ffd383, anthropic 1.13.0, openai 3.29.0
anthropic/with_raw_response {'gen_ai.response.id': False, 'gen_ai.response.finish_reasons': False, 'gen_ai.usage.input_tokens': False, 'gen_ai.usage.output_tokens': False, 'gen_ai.response.text': False} unknown_response
anthropic/with_streaming_response {'gen_ai.response.id': False, 'gen_ai.response.finish_reasons': False, 'gen_ai.usage.input_tokens': False, 'gen_ai.usage.output_tokens': False, 'gen_ai.response.text': False} unknown_response
openai/with_raw_response {'gen_ai.usage.input_tokens': False, 'gen_ai.usage.output_tokens': False, 'gen_ai.response.text': False}
openai/with_streaming_response {'gen_ai.usage.input_tokens': False, 'gen_ai.usage.output_tokens': False, 'gen_ai.response.text': False}
After:
$ python -W ignore repro.py # this branch
anthropic/with_raw_response {'gen_ai.response.id': True, 'gen_ai.response.finish_reasons': True, 'gen_ai.usage.input_tokens': True, 'gen_ai.usage.output_tokens': True, 'gen_ai.response.text': True}
anthropic/with_streaming_response {'gen_ai.response.id': True, 'gen_ai.response.finish_reasons': True, 'gen_ai.usage.input_tokens': True, 'gen_ai.usage.output_tokens': True, 'gen_ai.response.text': True}
openai/with_raw_response {'gen_ai.usage.input_tokens': True, 'gen_ai.usage.output_tokens': True, 'gen_ai.response.text': True}
openai/with_streaming_response {'gen_ai.usage.input_tokens': True, 'gen_ai.usage.output_tokens': True, 'gen_ai.response.text': True}
parse() caches its result, so parsing an already-read body where create would costs the caller nothing. A streamed body stays unread. The span fills when the caller parses it, and closes when the caller closes the response. A wrapper the caller neither parses nor closes leaves that span unfinished. The SDK then drops the span where baseline ends it. close() finishes the span wherever the wrapper offers one, and none of the 6 new tests covers that case.
Verification
$ python -m pytest -o addopts="" tests/integrations/anthropic/ tests/integrations/openai/ -q
1290 passed, 1716 warnings in 25.90s
$ python -m pytest -o addopts="" tests/ -q -p no:randomly --ignore=tests/integrations/wsgi --ignore=tests/test_client.py
194 failed, 3083 passed, 171 skipped, 1938 warnings, 390 errors in 198.87s
# baseline 2ffd383, same command: 194 failed, 3077 passed, 171 skipped, 1928 warnings, 390 errors in 179.49s
# not run: the tests/integrations/wsgi and tests/test_client.py collections (werkzeug missing, one integration unavailable here)
$ python -m ruff format sentry_sdk/integrations/anthropic.py sentry_sdk/integrations/openai.py tests/integrations/anthropic/test_raw_response.py tests/integrations/openai/test_raw_response.py && python -m ruff check sentry_sdk/integrations/anthropic.py sentry_sdk/integrations/openai.py tests/integrations/anthropic/test_raw_response.py tests/integrations/openai/test_raw_response.py
4 files left unchanged
All checks passed!
Baseline on 2ffd383 is 1284 passed, 1706 warnings in 26.98s, so the delta is the 6 new tests. Reverting both integration files and keeping the tests gives 6 failed, 10 warnings in 0.44s.
Your #5917, after #5890, stopped wrapping responses without _iterator. It said tracing LegacyAPIResponse was intentionally out of scope. This change keeps that guard and picks up only the deferral. It fills the span for the wrapper without touching _iterator or reading an unread body.
Fixes #7948
@alexander-alderman-webb Your #7948 reply put this on PY-2950. #7891 is the separate parse() gap on a plain create, which I have not touched here. If the openai work has started, I would close this instead. Otherwise it is ready to land ahead of PY-2950. Does that timing suit you?
Open Graph Description: fix(integrations): record output for with_raw_response and with_streaming_response
Description
sentry_sdk/integrations/anthropic.py:794 requires hasattr(result, "content"). A .with_raw_re...
X Description: fix(integrations): record output for with_raw_response and with_streaming_response
Description
sentry_sdk/integrations/anthropic.py:794 requires hasattr(result, "content"). A .wit...
Opengraph URL: https://github.com/getsentry/sentry-python/pull/8039
X: @github
direct link
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f990344a-24c5-033c-4fa0-4fc13894f0d5 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B0BE:33D24F:5B71F3:77455B:6B00DEB3 |
| html-safe-nonce | 6a4223504cd86ed2c701c8c1913a6a97698b4aad88cbf343d6adcf972e246e0c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMEJFOjMzRDI0Rjo1QjcxRjM6Nzc0NTVCOjZCMDBERUIzIiwidmlzaXRvcl9pZCI6IjE1NTc1MDQ0MTQ5MTMxOTE2MDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 84735386c19769b21039795da222ae1dfe200973e9956e284ce2c1a27d8113f6 |
| hovercard-subject-tag | pull_request:4864406723 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | ///pull_requests/show/files |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/getsentry/sentry-python/pull/8039/files |
| twitter:image | https://avatars.githubusercontent.com/u/48338417?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/48338417?s=400&v=4 |
| og:image:alt | fix(integrations): record output for with_raw_response and with_streaming_response
Description
sentry_sdk/integrations/anthropic.py:794 requires hasattr(result, "content"). A .with_raw_re... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Skip to content | https://github.com/getsentry/sentry-python/pull/8039/files#start-of-content |
| https://github.com/ |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fpull%2F8039%2Ffiles |
| GitHubRepository hosting, code review, and collaboration | https://github.com/platform |
| CopilotAI coding agent for tasks, projects, and automated work | https://github.com/features/copilot |
| ActionsCI/CD and automation | https://github.com/features/actions |
| Code QualityQuality analysis, fixes, and enforcement | https://github.com/features/code-quality |
| CodespacesCloud development environments | https://github.com/features/codespaces |
| Code SecurityVulnerability detection and remediation | https://github.com/security/advanced-security/code-security |
| Secret ProtectionSecret scanning and leak prevention | https://github.com/security/advanced-security/secret-protection |
| All Features | https://github.com/features |
| Documentation | https://docs.github.com/en |
| Training | https://learn.github.com/skills |
| Certifications | https://learn.github.com/credentials |
| Build with Copilot | https://github.com/features/ai |
| Customize Copilot | https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview |
| Integrations | https://github.com/marketplace |
| Trending repos | https://github.com/trending |
| GitHub Sponsors | https://github.com/open-source/sponsors |
| Developer articles | https://github.com/resources/articles |
| ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place. | https://github.blog/changelog/ |
| Enterprises | https://github.com/enterprise |
| Team | https://github.com/team |
| Startups | https://github.com/enterprise/startups |
| Nonprofits | https://github.com/solutions/industry/nonprofits |
| Healthcare | https://github.com/solutions/industry/healthcare |
| Financial services | https://github.com/solutions/industry/financial-services |
| Manufacturing | https://github.com/solutions/industry/manufacturing |
| Government | https://github.com/solutions/industry/government |
| See all industries | https://github.com/solutions/industry |
| Why GitHub | https://github.com/why-github |
| Customer Stories | https://github.com/customer-stories |
| Business insights | https://github.com/solutions/executive-insights |
| Trust Center | https://github.com/trust-center |
| GitHub Advanced SecurityEnterprise-grade code security | https://github.com/security/advanced-security |
| Copilot for businessEnterprise-grade AI features | https://github.com/features/copilot/copilot-business |
| Premium SupportEnterprise-grade 24/7 support | https://github.com/enterprise/premium-support |
| Documentation | https://docs.github.com/en |
| Resource center | https://github.com/resources |
| Blog | https://github.blog/ |
| Events & webinars | https://github.com/resources/events |
| Community Forum | https://github.com/orgs/community/discussions |
| Customer Stories | https://github.com/customer-stories |
| Integrations | https://github.com/marketplace |
| Customer support | https://help.github.com/ |
| Training | https://learn.github.com/skills |
| GitHub Status | https://www.githubstatus.com/ |
| About | https://github.com/about |
| Partners | https://github.com/partners |
| Changelog | https://github.blog/changelog/ |
| GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub. | https://githubuniverse.com/ |
| Pricing | https://github.com/pricing |
| Sign in | https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fpull%2F8039%2Ffiles |
| Sign up | https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=getsentry%2Fsentry-python |
| Reload | https://github.com/getsentry/sentry-python/pull/8039/files |
| Reload | https://github.com/getsentry/sentry-python/pull/8039/files |
| Reload | https://github.com/getsentry/sentry-python/pull/8039/files |
| getsentry | https://github.com/getsentry |
| sentry-python | https://github.com/getsentry/sentry-python |
| Code | https://github.com/getsentry/sentry-python |
| Issues345 (345) | https://github.com/getsentry/sentry-python/issues |
| Pull requests42 (42) | https://github.com/getsentry/sentry-python/pulls |
| Discussions | https://github.com/getsentry/sentry-python/discussions |
| Actions | https://github.com/getsentry/sentry-python/actions |
| Security and quality2 (2) | https://github.com/getsentry/sentry-python/security |
| Insights | https://github.com/getsentry/sentry-python/insights |
| Sign up for GitHub
| https://github.com/signup?return_to=%2Fgetsentry%2Fsentry-python%2Fissues%2Fnew%2Fchoose |
| terms of service | https://docs.github.com/terms |
| privacy statement | https://docs.github.com/privacy |
| Sign in | https://github.com/login?return_to=%2Fgetsentry%2Fsentry-python%2Fissues%2Fnew%2Fchoose |
| chrikrah | https://github.com/chrikrah |
| getsentry:master | https://github.com/getsentry/sentry-python/tree/master |
| chrikrah:fix/integrations-raw-response-output | https://github.com/chrikrah/sentry-python/tree/fix/integrations-raw-response-output |
|
Conversation
1
| https://github.com/getsentry/sentry-python/pull/8039 |
|
Commits
1
| https://github.com/getsentry/sentry-python/pull/8039/commits |
|
Checks
3
| https://github.com/getsentry/sentry-python/pull/8039/checks |
|
Files changed
| https://github.com/getsentry/sentry-python/pull/8039/files |
| Please reload this page | https://github.com/getsentry/sentry-python/pull/8039/files |
|
fix(integrations): record output for with_raw_response and with_streaming_response
| https://github.com/getsentry/sentry-python/pull/8039/files#top |
|
Show all changes
1 commit
| https://github.com/getsentry/sentry-python/pull/8039/files |
|
74ceaec
fix(integrations): record output for with_raw_response and with_strea…
chrikrah Oct 14, 2026
| https://github.com/getsentry/sentry-python/pull/8039/commits/74ceaec1ad4e267865fc98f5da548c870dcb26a8 |
|
Clear filters
| https://github.com/getsentry/sentry-python/pull/8039/files |
| Please reload this page | https://github.com/getsentry/sentry-python/pull/8039/files |
| Please reload this page | https://github.com/getsentry/sentry-python/pull/8039/files |
|
anthropic.py
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
openai.py
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-8be672624748ac6598fe3d702a6beaf03e1fa6bc3c5f8aeadf68158d401fe34e |
|
test_raw_response.py
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-598c493f55574b12a508666837e73b34d669481da566756bd892e2d904245fa8 |
|
test_raw_response.py
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-ecca973e08324ae5b86f1bca10297f0552747117960af0108a400b4a081bba89 |
|
| https://github.com/getsentry/sentry-python/blob/master/.github/CODEOWNERS#L1 |
| sentry_sdk/integrations/anthropic.py | https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
View file
| https://github.com/chrikrah/sentry-python/blob/74ceaec1ad4e267865fc98f5da548c870dcb26a8/sentry_sdk/integrations/anthropic.py |
|
Open in desktop
| https://desktop.github.com |
| https://github.co/hiddenchars |
| https://github.com/getsentry/sentry-python/pull/8039/{{ revealButtonHref }} |
|
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
|
| https://github.com/getsentry/sentry-python/pull/8039/files#diff-2fe73f39bab33821a7af1fccb0fd22b943b931b2cbf8d13aead2784b3cd21e05 |
| Please reload this page | https://github.com/getsentry/sentry-python/pull/8039/files |
|
| https://github.com |
| Terms | https://docs.github.com/site-policy/github-terms/github-terms-of-service |
| Privacy | https://docs.github.com/site-policy/privacy-policies/github-privacy-statement |
| Security | https://github.com/security |
| Status | https://www.githubstatus.com/ |
| Community | https://github.community/ |
| Docs | https://docs.github.com/ |
| Contact | https://support.github.com?tags=dotcom-footer |
Viewport: width=device-width
URLs of crawlers that visited me.