René's URL Explorer Experiment


Title: OpenAI and Anthropic integrations record no output or usage for `with_raw_response` and `with_streaming_response` calls · Issue #7948 · getsentry/sentry-python · GitHub

Open Graph Title: OpenAI and Anthropic integrations record no output or usage for `with_raw_response` and `with_streaming_response` calls · Issue #7948 · getsentry/sentry-python

X Title: OpenAI and Anthropic integrations record no output or usage for `with_raw_response` and `with_streaming_response` calls · Issue #7948 · getsentry/sentry-python

Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.71.0 (master 7cb8094) Steps to Reproduce client.messages.with_raw_response.create(...) and client.messages.with_streaming_response.create(...) get a gen_ai.chat span with no respon...

Open Graph Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.71.0 (master 7cb8094) Steps to Reproduce client.messages.with_raw_response.create(...) and client.messages.with_streaming_response.create(.....

X Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.71.0 (master 7cb8094) Steps to Reproduce client.messages.with_raw_response.create(...) and client.messages.with_streaming_response.create(.....

Opengraph URL: https://github.com/getsentry/sentry-python/issues/7948

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OpenAI and Anthropic integrations record no output or usage for `with_raw_response` and `with_streaming_response` calls","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n2.71.0 (master 7cb8094)\n\n### Steps to Reproduce\n\n`client.messages.with_raw_response.create(...)` and `client.messages.with_streaming_response.create(...)` get a `gen_ai.chat` span with no response id, finish reason, token usage or response text. Both return an `APIResponse` and not a `Message`, so the `hasattr(result, \"content\")` check in [anthropic.py#L794](https://github.com/getsentry/sentry-python/blob/7cb80948cbdefb10831740c23b49e56e348532a5/sentry_sdk/integrations/anthropic.py#L794) fails and the span gets `unknown_response`. The OpenAI integration loses the same data on both calls.\n\n```python\nimport httpx2, anthropic, sentry_sdk\nfrom sentry_sdk.integrations.anthropic import AnthropicIntegration\n\nBODY = {\"id\": \"msg_01\", \"type\": \"message\", \"role\": \"assistant\", \"model\": \"claude-sonnet-4-5\",\n        \"content\": [{\"type\": \"text\", \"text\": \"hi there\"}], \"stop_reason\": \"end_turn\",\n        \"stop_sequence\": None, \"usage\": {\"input_tokens\": 7, \"output_tokens\": 3}}\nevents = []\nsentry_sdk.init(dsn=\"https://k@o0.ingest.sentry.io/0\", traces_sample_rate=1.0, send_default_pii=True,\n                integrations=[AnthropicIntegration(include_prompts=True)],\n                before_send_transaction=lambda e, h: (events.append(e), None)[1])\nclient = anthropic.Anthropic(api_key=\"x\", http_client=httpx2.Client(transport=httpx2.MockTransport(lambda r: httpx2.Response(200, json=BODY))))\nkw = dict(model=\"claude-sonnet-4-5\", max_tokens=10, messages=[{\"role\": \"user\", \"content\": \"hello\"}])\n\nfor label in (\"create\", \"with_raw_response\", \"with_streaming_response\"):\n    with sentry_sdk.start_transaction(name=label):\n        if label == \"create\":\n            client.messages.create(**kw)\n        elif label == \"with_raw_response\":\n            client.messages.with_raw_response.create(**kw).parse()\n        else:\n            with client.messages.with_streaming_response.create(**kw) as r:\n                r.parse()\n\nKEYS = (\"gen_ai.response.id\", \"gen_ai.response.finish_reasons\", \"gen_ai.usage.input_tokens\", \"gen_ai.usage.output_tokens\", \"gen_ai.response.text\")\nfor e in events:\n    for s in e[\"spans\"]:\n        if s[\"op\"] == \"gen_ai.chat\":\n            d = s.get(\"data\", {})\n            print(f\"{e['transaction']:24}\", {k: k in d for k in KEYS}, \"unknown_response\" if d.get(\"unknown_response\") else \"\")\n```\n\n### Expected Result\n\nThe raw and streaming calls carry the same `gen_ai.*` data as `create`.\n\n### Actual Result\n\n```\n$ python -W ignore repro.py    # master 7cb8094, anthropic 1.13.0\ncreate                   {'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}\nwith_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\nwith_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\n\n# the same loop on client.chat.completions with OpenAIIntegration and three keys, openai 3.29.0\ncreate                   {'gen_ai.usage.input_tokens': True, 'gen_ai.usage.output_tokens': True, 'gen_ai.response.text': True}\nwith_raw_response        {'gen_ai.usage.input_tokens': False, 'gen_ai.usage.output_tokens': False, 'gen_ai.response.text': False}\nwith_streaming_response  {'gen_ai.usage.input_tokens': False, 'gen_ai.usage.output_tokens': False, 'gen_ai.response.text': False}\n# not run: the async clients, or a real endpoint\n```\n\nFor `with_raw_response` the body is already read when `create` returns, so I'd parse it there and end the span the way `create` does. `parse()` caches its result, so the caller pays nothing for it. Only `with_streaming_response` needs the `Stream` treatment from `_sentry_patched_create_sync`: wrap `parse()` to set the output and `close()` to end the span, since parsing at return would buffer a body the caller asked to stream.\n\nRelated: #5939 would still route these to `unknown_response`, because an `APIResponse` has no `type`, and #7891 is the `parse()` gap next to it.\n\n@alexander-alderman-webb this is the span-lifetime question from #7847 again, for `APIResponse`. I'd fix both in one change, since both touch `openai.py`. Is that already in the work you have planned for #7891?\n","author":{"url":"https://github.com/chrikrah","@type":"Person","name":"chrikrah"},"datePublished":"2026-10-12T07:12:34Z","url":"https://github.com/getsentry/sentry-python/issues/7948"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5e561355-2ba5-695e-e929-a2380014772a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9A14:14ECB:6DFC1:8F640:6B00C523
html-safe-nonce003ae647016703d8e30513757ecfcf9a1a844e8a58258bbf0f94e75a8178cda8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTE0OjE0RUNCOjZERkMxOjhGNjQwOjZCMDBDNTIzIiwidmlzaXRvcl9pZCI6IjM0NjE4MTczMzU0MjAwNzczNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace8a11ba37b13d710badb7c480f1bd1e995f2cf93026b44eb0ee541011b4eba1d
hovercard-subject-tagissue:5809808550
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/7948/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f317bf9613f50dbd2d462510d80011dcae24ac66f71a4d8706dc0bbc8c8bd747/getsentry/sentry-python/issues/7948
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f317bf9613f50dbd2d462510d80011dcae24ac66f71a4d8706dc0bbc8c8bd747/getsentry/sentry-python/issues/7948
og:image:altHow do you use Sentry? Sentry Saas (sentry.io) Version 2.71.0 (master 7cb8094) Steps to Reproduce client.messages.with_raw_response.create(...) and client.messages.with_streaming_response.create(.....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamechrikrah
hostnamegithub.com
expected-hostnamegithub.com
None93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id137814779
octolytics-dimension-repository_nwogetsentry/sentry-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id137814779
octolytics-dimension-repository_network_root_nwogetsentry/sentry-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1fee81a280ea86312b69448e261b418189bfd5b5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/issues/7948#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F7948
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fissues%2F7948
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-python
Reloadhttps://github.com/getsentry/sentry-python/issues/7948
Reloadhttps://github.com/getsentry/sentry-python/issues/7948
Reloadhttps://github.com/getsentry/sentry-python/issues/7948
getsentryhttps://github.com/getsentry
sentry-pythonhttps://github.com/getsentry/sentry-python
Codehttps://github.com/getsentry/sentry-python
Issues345 (345)https://github.com/getsentry/sentry-python/issues
Pull requests42 (42)https://github.com/getsentry/sentry-python/pulls
Discussionshttps://github.com/getsentry/sentry-python/discussions
Actionshttps://github.com/getsentry/sentry-python/actions
Security and quality2 (2)https://github.com/getsentry/sentry-python/security
Insightshttps://github.com/getsentry/sentry-python/insights
https://github.com/getsentry/sentry-python
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/7948
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/7948
OpenAI and Anthropic integrations record no output or usage for with_raw_response and with_streaming_response callshttps://github.com/getsentry/sentry-python/issues/7948#top
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
Spanshttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Spans%22
https://github.com/chrikrah
chrikrahhttps://github.com/chrikrah
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948#issue-5809808550
7cb8094https://github.com/getsentry/sentry-python/commit/7cb80948cbdefb10831740c23b49e56e348532a5
anthropic.py#L794https://github.com/getsentry/sentry-python/blob/7cb80948cbdefb10831740c23b49e56e348532a5/sentry_sdk/integrations/anthropic.py#L794
#5939https://github.com/getsentry/sentry-python/issues/5939
#7891https://github.com/getsentry/sentry-python/issues/7891
@alexander-alderman-webbhttps://github.com/alexander-alderman-webb
#7847https://github.com/getsentry/sentry-python/issues/7847
#7891https://github.com/getsentry/sentry-python/issues/7891
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948#event-33026068614
https://github.com/apps/linear-code
linear-codehttps://github.com/apps/linear-code
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948#issuecomment-6119521939
Linear Codehttps://linear.app
PY-2950https://linear.app/getsentry/issue/PY-2950
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948#event-33101790765
linear-codehttps://github.com/apps/linear-code
Spanshttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Spans%22
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948#event-33026097876
https://github.com/alexander-alderman-webb
alexander-alderman-webbhttps://github.com/alexander-alderman-webb
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948#issuecomment-6119639620
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948#event-33026573186
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Oct 12, 2026https://github.com/getsentry/sentry-python/issues/7948
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-python/issues/7948
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-python/issues/7948
Bughttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Bug%22
PythonSDKhttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Python%22
Spanshttps://github.com/getsentry/sentry-python/issues?q=state%3Aopen%20label%3A%22Spans%22
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.