Skip to content

ref(core): Do not emit spans for chats.create in google-genai#19990

Open
nicohrubec wants to merge 11 commits intodevelopfrom
nh/no-chats-create-span
Open

ref(core): Do not emit spans for chats.create in google-genai#19990
nicohrubec wants to merge 11 commits intodevelopfrom
nh/no-chats-create-span

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec commented Mar 26, 2026

We currently emit spans for the google-genai chats.create() API. I think this is basically useless because chats.create() doesn't represent an actual interaction with an LLM model, instead it just constructs a local chat object as a result that then further exposes methods like sendMessage() that represent actual LLM interactions. This PR removes the spans for chats.create().

Since this API is a special case where we actually need to proxy the return object instead of the method call itself we had some surrounding logic hardcoded to this method. To make this a bit more future proof and also more explicit we now add a proxyResultPath field to the method registry that allows to define this behavior in the method registry without needing any hardcoded logic. Another benefit this has is that the full logic in the createDeepProxy methods in all our client-proxy based AI integrations (google-genai, openai, anthropic) is now essentially the same so could potentially in the future be easily merged into a shared abstraction.

Limitation: We do"loose" some data by not emitting this create span anymore, because the way this API works is that the user defines certain parameters only on the chats.create() call and these are then subsequently used for each chat.sendMessage() call. The correct way would be to send this data as part of each chat.sendMessage() chat span. We can think about doing this as part of this PR or doing a follow up.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (core, node) Portable Express integration by isaacs in #19928
  • (deno) Add denoRuntimeMetricsIntegration by chargome in #20023
  • (deps) Bump @xmldom/xmldom from 0.8.3 to 0.8.12 by dependabot in #20066

Bug Fixes 🐛

  • (aws-serverless) Add timeout to _endSpan forceFlush to prevent Lambda hanging by logaretm in #20064
  • (cloudflare) Ensure every request instruments functions by JPeer264 in #20044
  • (gatsby) Fix errorHandler signature to match bundler-plugin-core API by JPeer264 in #20048

Internal Changes 🔧

Core

  • Do not emit spans for chats.create in google-genai by nicohrubec in #19990
  • Extract shared endStreamSpan for AI integrations by nicohrubec in #20021
  • Remove provider-specific AI span attributes in favor of gen_ai attributes in sentry conventions by nicohrubec in #20011

Other

  • Update validate-pr workflow by stephanie-anderson in #20072
  • Remove unused tsconfig-template folder by mydea in #20067

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.69 kB +0.17% +43 B 🔺
@sentry/browser - with treeshaking flags 24.17 kB +0.17% +40 B 🔺
@sentry/browser (incl. Tracing) 42.17 kB +0.06% +25 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.79 kB +0.07% +31 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.98 kB +0.06% +45 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.6 kB +0.06% +37 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.7 kB +0.07% +53 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.97 kB +0.06% +56 B 🔺
@sentry/browser (incl. Feedback) 42.48 kB +0.14% +57 B 🔺
@sentry/browser (incl. sendFeedback) 30.35 kB +0.17% +51 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.4 kB +0.35% +120 B 🔺
@sentry/browser (incl. Metrics) 26.96 kB +0.03% +6 B 🔺
@sentry/browser (incl. Logs) 27.1 kB -0.01% -2 B 🔽
@sentry/browser (incl. Metrics & Logs) 27.78 kB +0.02% +5 B 🔺
@sentry/react 27.45 kB +0.15% +41 B 🔺
@sentry/react (incl. Tracing) 44.52 kB +0.1% +41 B 🔺
@sentry/vue 30.13 kB +0.18% +53 B 🔺
@sentry/vue (incl. Tracing) 44.08 kB +0.08% +32 B 🔺
@sentry/svelte 25.7 kB +0.16% +40 B 🔺
CDN Bundle 28.39 kB +0.28% +79 B 🔺
CDN Bundle (incl. Tracing) 43.2 kB +0.22% +94 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.76 kB +0.27% +80 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 44.25 kB +0.22% +94 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.56 kB +0.12% +79 B 🔺
CDN Bundle (incl. Tracing, Replay) 80.08 kB +0.11% +81 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.16 kB +0.15% +115 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.62 kB +0.09% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.67 kB +0.12% +97 B 🔺
CDN Bundle - uncompressed 82.93 kB +0.33% +266 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 128.07 kB +0.21% +266 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.07 kB +0.31% +266 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 131.48 kB +0.21% +266 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 210.06 kB +0.13% +266 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.95 kB +0.11% +266 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 248.34 kB +0.11% +266 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.86 kB +0.11% +266 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 261.25 kB +0.11% +266 B 🔺
@sentry/nextjs (client) 46.93 kB +0.09% +41 B 🔺
@sentry/sveltekit (client) 42.67 kB +0.13% +53 B 🔺
@sentry/node-core 56.51 kB +1.36% +756 B 🔺
@sentry/node 173.59 kB +0.49% +839 B 🔺
@sentry/node - without tracing 96.54 kB +0.55% +527 B 🔺
@sentry/aws-serverless 113.54 kB +0.68% +765 B 🔺

View base workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,333 - 11,213 -17%
GET With Sentry 1,720 18% 1,972 -13%
GET With Sentry (error only) 5,886 63% 7,611 -23%
POST Baseline 1,194 - 1,281 -7%
POST With Sentry 588 49% 627 -6%
POST With Sentry (error only) 1,062 89% 1,132 -6%
MYSQL Baseline 3,266 - 3,494 -7%
MYSQL With Sentry 497 15% 456 +9%
MYSQL With Sentry (error only) 2,658 81% 2,814 -6%

View base workflow run

@nicohrubec nicohrubec changed the title Nh/no chats create span ref(core): Do not emit spans for chats.create in google-genai Mar 26, 2026
@nicohrubec nicohrubec force-pushed the nh/no-chats-create-span branch from 042667f to cb797a1 Compare March 26, 2026 14:44
@nicohrubec nicohrubec force-pushed the nh/no-chats-create-span branch from 16c5086 to 15e6af4 Compare March 27, 2026 13:46
@nicohrubec nicohrubec marked this pull request as ready for review March 27, 2026 14:01
@nicohrubec nicohrubec requested a review from andreiborza March 27, 2026 14:01
Copy link
Copy Markdown
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

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

LGTM, could you please create an issue for carrying over the data we lose by not creating these spans anymore?

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