René's URL Explorer Experiment


Title: feat(boto3): Instrument Bedrock Runtime InvokeModel calls as gen_ai spans by sentry-junior[bot] · Pull Request #8187 · getsentry/sentry-python · GitHub

Open Graph Title: feat(boto3): Instrument Bedrock Runtime InvokeModel calls as gen_ai spans by sentry-junior[bot] · Pull Request #8187 · getsentry/sentry-python

X Title: feat(boto3): Instrument Bedrock Runtime InvokeModel calls as gen_ai spans by sentry-junior[bot] · Pull Request #8187 · getsentry/sentry-python

Description: Description This PR (2 of 3, stacked on #8186) records InvokeModel as a generate_content {modelId} span with op gen_ai.generate_content (new OP.GEN_AI_GENERATE_CONTENT). It matches the JS SDK. The request and response bodies have a model-specific format. Like JS, this parses them per model family: Anthropic Claude (including inference profile IDs like us.anthropic...), Amazon Nova and Titan, Meta Llama, Cohere Command and Command R, and Mistral. Prompts and responses use the same gating as Converse: data_collection.gen_ai.inputs/outputs independently, else send_default_pii with include_prompts. Decisions the diff doesn't show: The SDK doesn't read the response body itself or replace the StreamingBody object. Instead, body.read, body.close, and body._raw_stream.close are patched on that instance, the same approach the S3 instrumentation on master uses. _patch_streaming_body() is extracted from it for this. The bytes are recorded as the caller reads them (read(), read(amt), iter_chunks()), and the span finishes when the body is fully read, closed, or a read fails. A new _ServiceExtension.instrument_response() hook lets an extension take over finishing the span. Token usage falls back to Bedrock's x-amzn-bedrock-input/output-token-count response headers when the body has none (Cohere, Mistral, unknown models, early close). This replaces JS's chars / 6 estimates. The request body is parsed once, in get_span_start_attributes(), for its parameters and input messages, so its parameters aren't visible to ignore_spans and spans it drops skip the parse. Request bodies passed as file objects aren't read. Request and response bodies over 1 MB (MAX_INVOKE_MODEL_BODY_BYTES) aren't parsed, e.g. requests with images or image generation results; response usage still comes from the headers. Malformed JSON bodies are skipped quietly. Media blocks (Claude image and document blocks, including images in tool_result, and Nova images) aren't recorded. Unknown model families still get the span, op, model, and header usage. Changelog note InvokeModel spans change from http.client / auto.http.boto3 to gen_ai.generate_content / auto.ai.boto3, and their name changes from aws.bedrock-runtime.InvokeModel to generate_content , which affects ignore_spans rules that match on the name. Boto3Integration is auto-enabled, so users with send_default_pii=True start sending InvokeModel prompts and responses unless they set Boto3Integration(include_prompts=False) or configure data_collection. Issues Refs #5470. Follow-ups, both matching JS today: amazon.titan-embed models match the Titan text family, so they get a generate_content span rather than an embeddings span, and newer Mistral chat formats (messages/choices) aren't parsed. via @dcramer. -- View Session [Sentry]

Open Graph Description: Description This PR (2 of 3, stacked on #8186) records InvokeModel as a generate_content {modelId} span with op gen_ai.generate_content (new OP.GEN_AI_GENERATE_CONTENT). It matches the JS SDK. The ...

X Description: Description This PR (2 of 3, stacked on #8186) records InvokeModel as a generate_content {modelId} span with op gen_ai.generate_content (new OP.GEN_AI_GENERATE_CONTENT). It matches the JS SDK. The ...

Opengraph URL: https://github.com/getsentry/sentry-python/pull/8187

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.4

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:b639f4ec-016e-df5e-2bfe-30137ff91809
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE708:3990B6:79AD12:AB38E8:6B04502A
html-safe-nonce0eaee4e9535636dbe04db504fdceb0afa9dea915077310816838b6ba0ef30a00
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzA4OjM5OTBCNjo3OUFEMTI6QUIzOEU4OjZCMDQ1MDJBIiwidmlzaXRvcl9pZCI6IjIyNjkyODA1OTAwNzM0NTA1MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacfbfe53d6f8cae3d4a35059b356f5d4fac26881608e21a32d443cf3c821df0273
hovercard-subject-tagpull_request:5162910176
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/getsentry/sentry-python/pull/8187/files
twitter:imagehttps://avatars.githubusercontent.com/in/2960336?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/in/2960336?s=400&v=4
og:image:altDescription This PR (2 of 3, stacked on #8186) records InvokeModel as a generate_content {modelId} span with op gen_ai.generate_content (new OP.GEN_AI_GENERATE_CONTENT). It matches the JS SDK. The ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None002aa6b95ffa730b0aec436a5c383f536ad677284e60056037fb120afe37b730
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release059f24c781e3a0d7df3f27a97da0e93fab06ae39
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/pull/8187/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fpull%2F8187%2Ffiles
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%2Fpull%2F8187%2Ffiles
Sign uphttps://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
Reloadhttps://github.com/getsentry/sentry-python/pull/8187/files
Reloadhttps://github.com/getsentry/sentry-python/pull/8187/files
Reloadhttps://github.com/getsentry/sentry-python/pull/8187/files
getsentryhttps://github.com/getsentry
sentry-pythonhttps://github.com/getsentry/sentry-python
Codehttps://github.com/getsentry/sentry-python
Issues340 (340)https://github.com/getsentry/sentry-python/issues
Pull requests35 (35)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
Sign up for GitHub https://github.com/signup?return_to=%2Fgetsentry%2Fsentry-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgetsentry%2Fsentry-python%2Fissues%2Fnew%2Fchoose
sentry-juniorhttps://github.com/apps/sentry-junior
junior/boto3-bedrock-conversehttps://github.com/getsentry/sentry-python/tree/junior/boto3-bedrock-converse
junior/boto3-bedrock-invoke-modelhttps://github.com/getsentry/sentry-python/tree/junior/boto3-bedrock-invoke-model
Conversation 2 https://github.com/getsentry/sentry-python/pull/8187
Commits 2 https://github.com/getsentry/sentry-python/pull/8187/commits
Checks 329 https://github.com/getsentry/sentry-python/pull/8187/checks
Files changed https://github.com/getsentry/sentry-python/pull/8187/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/8187/files
feat(boto3): Instrument Bedrock Runtime InvokeModel calls as gen_ai spans https://github.com/getsentry/sentry-python/pull/8187/files#top
Show all changes 2 commits https://github.com/getsentry/sentry-python/pull/8187/files
1a1f370 feat(boto3): Instrument Bedrock Runtime InvokeModel calls as gen_ai s… sentry-junior[bot] Nov 4, 2026 https://github.com/getsentry/sentry-python/pull/8187/commits/1a1f370bffda84cd4d16cdc920d9daf86de6a6ea
b8c2634 fix(boto3): Skip large or malformed Bedrock InvokeModel request bodies sentry-junior[bot] Nov 4, 2026 https://github.com/getsentry/sentry-python/pull/8187/commits/b8c26346e3836d54e2105ac5644953a751ac831a
Clear filters https://github.com/getsentry/sentry-python/pull/8187/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/8187/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/8187/files
consts.py https://github.com/getsentry/sentry-python/pull/8187/files#diff-719f41f07f1275f8a1b02085180aa234b257226fc976d776ebef5d8dff9db017
_client.py https://github.com/getsentry/sentry-python/pull/8187/files#diff-3dce192e1b01eabfb3f710ea6c19a132b0c97740d76f3b058ad41d6f5b63f9b9
_instrumentation.py https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
base.py https://github.com/getsentry/sentry-python/pull/8187/files#diff-f575de59e6e13d55e371295b60d2add991777271bbaf41f9743229460208fe51
bedrock_runtime.py https://github.com/getsentry/sentry-python/pull/8187/files#diff-43f466f3e11d254754d2935df7d1b46275f200462642e57d082240890e6edacd
test_bedrock_runtime.py https://github.com/getsentry/sentry-python/pull/8187/files#diff-431dbe73ff4d6b4b842f1d4d758a7c82ed4b96702c9647addd00d0a4c1b72b4d
https://github.com/getsentry/sentry-python/blob/master/.github/CODEOWNERS#L1
sentry_sdk/consts.pyhttps://github.com/getsentry/sentry-python/pull/8187/files#diff-719f41f07f1275f8a1b02085180aa234b257226fc976d776ebef5d8dff9db017
View file https://github.com/getsentry/sentry-python/blob/b8c26346e3836d54e2105ac5644953a751ac831a/sentry_sdk/consts.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/getsentry/sentry-python/pull/8187/{{ revealButtonHref }}
https://github.com/getsentry/sentry-python/pull/8187/files#diff-719f41f07f1275f8a1b02085180aa234b257226fc976d776ebef5d8dff9db017
https://github.com/getsentry/sentry-python/pull/8187/files#diff-719f41f07f1275f8a1b02085180aa234b257226fc976d776ebef5d8dff9db017
https://github.com/getsentry/sentry-python/blob/master/.github/CODEOWNERS#L1
sentry_sdk/integrations/boto3/_client.pyhttps://github.com/getsentry/sentry-python/pull/8187/files#diff-3dce192e1b01eabfb3f710ea6c19a132b0c97740d76f3b058ad41d6f5b63f9b9
View file https://github.com/getsentry/sentry-python/blob/b8c26346e3836d54e2105ac5644953a751ac831a/sentry_sdk/integrations/boto3/_client.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/getsentry/sentry-python/pull/8187/{{ revealButtonHref }}
https://github.com/getsentry/sentry-python/pull/8187/files#diff-3dce192e1b01eabfb3f710ea6c19a132b0c97740d76f3b058ad41d6f5b63f9b9
https://github.com/getsentry/sentry-python/pull/8187/files#diff-3dce192e1b01eabfb3f710ea6c19a132b0c97740d76f3b058ad41d6f5b63f9b9
https://github.com/getsentry/sentry-python/blob/master/.github/CODEOWNERS#L1
sentry_sdk/integrations/boto3/_instrumentation.pyhttps://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
View file https://github.com/getsentry/sentry-python/blob/b8c26346e3836d54e2105ac5644953a751ac831a/sentry_sdk/integrations/boto3/_instrumentation.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/getsentry/sentry-python/pull/8187/{{ revealButtonHref }}
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/pull/8187/files#diff-5d72e4fbd709067f1b6c291d002a90436d530ee2837778e59f2b76c630264ea3
https://github.com/getsentry/sentry-python/blob/master/.github/CODEOWNERS#L1
sentry_sdk/integrations/boto3/_services/base.pyhttps://github.com/getsentry/sentry-python/pull/8187/files#diff-f575de59e6e13d55e371295b60d2add991777271bbaf41f9743229460208fe51
View file https://github.com/getsentry/sentry-python/blob/b8c26346e3836d54e2105ac5644953a751ac831a/sentry_sdk/integrations/boto3/_services/base.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/getsentry/sentry-python/pull/8187/{{ revealButtonHref }}
https://github.com/getsentry/sentry-python/pull/8187/files#diff-f575de59e6e13d55e371295b60d2add991777271bbaf41f9743229460208fe51
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/8187/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/8187/files
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.