Skip to content

ref(core): Introduce instrumented method registry for AI integrations - #19981

Merged
nicohrubec merged 18 commits into
developfrom
nh/consolidate-operation-api-path
Mar 26, 2026
Merged

ref(core): Introduce instrumented method registry for AI integrations#19981
nicohrubec merged 18 commits into
developfrom
nh/consolidate-operation-api-path

Conversation

@nicohrubec

@nicohrubecnicohrubec commented Mar 25, 2026

Copy link
Copy Markdown
Member

Replace the shared getOperationName() function with per-provider method registries that map API paths to their operation name and streaming behavior. This explicitly couples the instrumented methods and necessary metadata in one place instead of having convoluted substring matching in multiple places that can be quite hard to reason about.

Closes#19987 (added automatically)

@github-actions

github-actionsBot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

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 ✨

  • (node) Add nodeRuntimeMetricsIntegration by chargome in #19923
  • (nuxt) Support parametrized SSR routes in Nuxt 5 by s1gr1d in #19977

Bug Fixes 🐛

  • (e2e) Pin @opentelemetry/api to 1.9.0 in ts3.8 test app by logaretm in #19992
  • (opentelemetry) Convert seconds timestamps in span.end() to milliseconds by logaretm in #19958

Documentation 📚

  • (release) Update publishing-a-release.md by nicohrubec in #19982

Internal Changes 🔧

Core

  • Introduce instrumented method registry for AI integrations by nicohrubec in #19981
  • Consolidate getOperationName into one shared utility by nicohrubec in #19971

Other

  • (deno) Expand Deno E2E test coverage by chargome in #19957

🤖 This preview updates automatically when you update the PR.

@github-actions

github-actionsBot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

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.

PathSize% ChangeChange
@sentry/browser25.69 kB+0.2%+49 B 🔺
@sentry/browser - with treeshaking flags24.17 kB+0.14%+33 B 🔺
@sentry/browser (incl. Tracing)42.67 kB+0.13%+54 B 🔺
@sentry/browser (incl. Tracing, Profiling)47.33 kB+0.12%+55 B 🔺
@sentry/browser (incl. Tracing, Replay)81.48 kB+0.08%+57 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags71.06 kB+0.1%+69 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas)86.17 kB+0.06%+50 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback)98.41 kB+0.04%+36 B 🔺
@sentry/browser (incl. Feedback)42.48 kB+0.08%+30 B 🔺
@sentry/browser (incl. sendFeedback)30.35 kB+0.15%+44 B 🔺
@sentry/browser (incl. FeedbackAsync)35.4 kB+0.12%+39 B 🔺
@sentry/browser (incl. Metrics)26.96 kB+0.14%+37 B 🔺
@sentry/browser (incl. Logs)27.1 kB+0.12%+32 B 🔺
@sentry/browser (incl. Metrics & Logs)27.78 kB+0.15%+39 B 🔺
@sentry/react27.45 kB+0.22%+58 B 🔺
@sentry/react (incl. Tracing)45.01 kB+0.14%+60 B 🔺
@sentry/vue30.13 kB+0.16%+46 B 🔺
@sentry/vue (incl. Tracing)44.52 kB+0.09%+39 B 🔺
@sentry/svelte25.7 kB+0.16%+40 B 🔺
CDN Bundle28.35 kB+0.27%+75 B 🔺
CDN Bundle (incl. Tracing)43.57 kB+0.15%+62 B 🔺
CDN Bundle (incl. Logs, Metrics)29.22 kB+0.27%+77 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics)44.43 kB+0.17%+75 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics)68.3 kB+0.13%+86 B 🔺
CDN Bundle (incl. Tracing, Replay)80.41 kB+0.1%+73 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)81.31 kB+0.1%+76 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)85.97 kB+0.12%+103 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)86.85 kB+0.1%+85 B 🔺
CDN Bundle - uncompressed82.7 kB+0.1%+77 B 🔺
CDN Bundle (incl. Tracing) - uncompressed128.62 kB+0.05%+64 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed85.57 kB+0.1%+77 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed131.49 kB+0.05%+64 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed209.22 kB+0.05%+102 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed245.5 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed248.35 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed258.41 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed261.26 kB+0.04%+89 B 🔺
@sentry/nextjs (client)47.4 kB+0.08%+37 B 🔺
@sentry/sveltekit (client)43.12 kB+0.12%+51 B 🔺
@sentry/node-core56.46 kB+0.2%+112 B 🔺
@sentry/node173.49 kB+0.19%+328 B 🔺
@sentry/node - without tracing96.47 kB+0.13%+123 B 🔺
@sentry/aws-serverless113.48 kB+0.13%+143 B 🔺

View base workflow run

@github-actions

github-actionsBot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

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.

ScenarioRequests/s% of BaselinePrev. Requests/sChange %
GET Baseline9,384-9,058+4%
GET With Sentry1,76919%1,677+5%
GET With Sentry (error only)6,19666%6,200-0%
POST Baseline1,199-1,190+1%
POST With Sentry59450%566+5%
POST With Sentry (error only)1,06188%1,057+0%
MYSQL Baseline3,276-3,307-1%
MYSQL With Sentry44614%470-5%
MYSQL With Sentry (error only)2,65481%2,684-1%

View base workflow run

@nicohrubecnicohrubec changed the title ref(core): Couple api and operation name in ai integrationsref(core): Introduce instrumented method registry for AI integrationsMar 26, 2026
@nicohrubec
nicohrubec marked this pull request as ready for review March 26, 2026 10:42
Comment threadpackages/core/src/index.ts Outdated

@chargomechargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, pls do a double-check if the types that got deleted were exported, bc then this would be breaking technically. Would mention this in the changelog if that's the case

'models.generateContentStream': { operation: 'generate_content', streaming: true },
'chats.create': { operation: 'chat' },
// chat.* paths are built by createDeepProxy when it proxies the chat instance with CHAT_PATH as base
'chat.sendMessage': { operation: 'chat' },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

l: we could actually use CHAT_PATH here instead of hardcoding

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I'll likely get rid of CHAT_PATH in a follow up, can think about introducing a more broad operations objects to handle all of these ops constants

Comment threadpackages/core/src/tracing/google-genai/constants.ts
@nicohrubec

Copy link
Copy Markdown
MemberAuthor

@chargome right they are exported (for reasons idk because they are not used anywhere it seems). I put them back in with a deprecation notice

@cursorcursorBot 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 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment threadpackages/core/src/tracing/openai/types.ts

@logaretmlogaretm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pretty good refactor

@nicohrubec
nicohrubec merged commit e3bdbed into developMar 26, 2026
464 of 469 checks passed
@nicohrubec
nicohrubec deleted the nh/consolidate-operation-api-path branch March 26, 2026 18:06
Sign up for freeto 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.

ref(core): Introduce instrumented method registry for AI integrations

3 participants

@nicohrubec@logaretm@chargome