Skip to content

feat(core): Support embeddings in langchain#20017

Open
nicohrubec wants to merge 18 commits intodevelopfrom
nh/langchain-embeddings
Open

feat(core): Support embeddings in langchain#20017
nicohrubec wants to merge 18 commits intodevelopfrom
nh/langchain-embeddings

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec commented Mar 27, 2026

Adds embeddings instrumentation for LangChain (embedQuery, embedDocuments). LangChain's Embeddings base class doesn't use the callback system that we rely on for chat models, so this uses direct prototype patching instead.

In Node.js, embedding classes from provider packages are auto-instrumented. For other runtimes:

const embeddings = Sentry.instrumentLangChainEmbeddings(
  new OpenAIEmbeddings({ model: 'text-embedding-3-small' })
);                                                                                                                          
await embeddings.embedQuery('Hello world');

Creates gen_ai.embeddings spans. Token usage is not available since LangChain's embedding methods only return raw vectors.

Closes #19774

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 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

  • Support embeddings in langchain by nicohrubec in #20017
  • Support embedding APIs in google-genai by nicohrubec in #19797

Deps

  • Bump babel-loader from 10.0.0 to 10.1.1 by dependabot in #19997
  • Bump handlebars from 4.7.7 to 4.7.9 by dependabot in #20008

Nuxt

  • Add middleware instrumentation compatibility for Nuxt 5 by s1gr1d in #19968
  • Support parametrized SSR routes in Nuxt 5 by s1gr1d in #19977

Other

  • (browser) Replace element timing spans with metrics by logaretm in #19869
  • (bun) Add bunRuntimeMetricsIntegration by chargome in #19979
  • (node) Add nodeRuntimeMetricsIntegration by chargome in #19923
  • (node-core) Add OTLP integration for node-core/light by andreiborza in #19729
  • (solid) Add route parametrization for Solid Router by andreiborza in #20031

Bug Fixes 🐛

Ci

  • Update validate-pr action to remove draft enforcement by stephanie-anderson in #20037
  • Update validate-pr action to remove draft enforcement by stephanie-anderson in #20035

Node

  • Deduplicate sentry-trace and baggage headers on outgoing requests by Lms24 in #19960
  • Ensure startNewTrace propagates traceId in OTel environments by logaretm in #19963

Other

  • (core) Guard nullish response in supabase PostgREST handler by antonis in #20033
  • (e2e) Pin @opentelemetry/api to 1.9.0 in ts3.8 test app by logaretm in #19992
  • (nuxt) Use virtual module for Nuxt pages data (SSR route parametrization) by s1gr1d in #20020
  • (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

Deps

  • Bump amqplib from 0.10.7 to 0.10.9 by dependabot in #20000
  • Bump actions/upload-artifact from 6 to 7 by dependabot in #19569
  • Bump srvx from 0.11.12 to 0.11.13 by dependabot in #20001
  • Bump @apollo/server from 5.4.0 to 5.5.0 by dependabot in #20007

Deps Dev

  • Remove esbuild override in astro-5-cf-workers E2E test by isaacs in #20024
  • Bump node-forge from 1.3.2 to 1.4.0 by dependabot in #20012
  • Bump yaml from 2.8.2 to 2.8.3 by dependabot in #19985

Other

  • (browser) Reduce browser package bundle size by HazAT in #19856
  • (deno) Expand Deno E2E test coverage by chargome in #19957
  • (e2e) Add e2e tests for nodeRuntimeMetricsIntegration by chargome in #19989

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 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.64 kB -0.17% -43 B 🔽
@sentry/browser - with treeshaking flags 24.13 kB -0.17% -40 B 🔽
@sentry/browser (incl. Tracing) 42.15 kB -0.06% -25 B 🔽
@sentry/browser (incl. Tracing, Profiling) 46.76 kB -0.07% -31 B 🔽
@sentry/browser (incl. Tracing, Replay) 80.94 kB -0.06% -45 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.56 kB -0.06% -37 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 85.65 kB -0.07% -53 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 97.91 kB -0.06% -56 B 🔽
@sentry/browser (incl. Feedback) 42.42 kB -0.14% -57 B 🔽
@sentry/browser (incl. sendFeedback) 30.3 kB -0.17% -51 B 🔽
@sentry/browser (incl. FeedbackAsync) 35.28 kB -0.34% -120 B 🔽
@sentry/browser (incl. Metrics) 26.95 kB -0.03% -6 B 🔽
@sentry/browser (incl. Logs) 27.1 kB +0.01% +2 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.77 kB -0.02% -5 B 🔽
@sentry/react 27.41 kB -0.15% -41 B 🔽
@sentry/react (incl. Tracing) 44.48 kB -0.1% -41 B 🔽
@sentry/vue 30.08 kB -0.18% -53 B 🔽
@sentry/vue (incl. Tracing) 44.05 kB -0.08% -32 B 🔽
@sentry/svelte 25.66 kB -0.16% -40 B 🔽
CDN Bundle 28.31 kB -0.28% -79 B 🔽
CDN Bundle (incl. Tracing) 43.1 kB -0.22% -94 B 🔽
CDN Bundle (incl. Logs, Metrics) 29.68 kB -0.27% -80 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 44.16 kB -0.22% -94 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 68.48 kB -0.12% -79 B 🔽
CDN Bundle (incl. Tracing, Replay) 80 kB -0.11% -81 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.04 kB -0.15% -115 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 85.54 kB -0.09% -75 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.58 kB -0.12% -97 B 🔽
CDN Bundle - uncompressed 82.66 kB -0.33% -266 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 127.81 kB -0.21% -266 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed 86.81 kB -0.31% -266 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 131.22 kB -0.21% -266 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 209.79 kB -0.13% -266 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.68 kB -0.11% -266 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 248.08 kB -0.11% -266 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.59 kB -0.11% -266 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.98 kB -0.11% -266 B 🔽
@sentry/nextjs (client) 46.89 kB -0.09% -41 B 🔽
@sentry/sveltekit (client) 42.62 kB -0.13% -53 B 🔽
@sentry/node-core 56.7 kB +0.37% +208 B 🔺
@sentry/node 174.22 kB +0.37% +630 B 🔺
@sentry/node - without tracing 96.77 kB +0.25% +237 B 🔺
@sentry/aws-serverless 113.76 kB +0.21% +232 B 🔺

View base workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 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,108 - 9,034 +1%
GET With Sentry 1,662 18% 1,534 +8%
GET With Sentry (error only) 5,848 64% 5,874 -0%
POST Baseline 1,185 - 1,126 +5%
POST With Sentry 567 48% 539 +5%
POST With Sentry (error only) 1,015 86% 996 +2%
MYSQL Baseline 3,129 - 3,101 +1%
MYSQL With Sentry 380 12% 383 -1%
MYSQL With Sentry (error only) 2,521 81% 2,512 +0%

View base workflow run

@nicohrubec nicohrubec marked this pull request as ready for review March 30, 2026 12:55
Copy link
Copy Markdown

@cursor cursor bot left a comment

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.

/**
* The span operation for embeddings
*/
export const GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE = 'gen_ai.embeddings';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicate constant with identical value adds confusion

Low Severity

GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE is a new constant with value 'gen_ai.embeddings', identical to the existing GEN_AI_EMBED_DO_EMBED_OPERATION_ATTRIBUTE and GEN_AI_EMBED_MANY_DO_EMBED_OPERATION_ATTRIBUTE. Having three exported constants with the same string value increases maintenance burden — a future change to the operation name would need to update all three, risking inconsistency.

Additional Locations (1)
Fix in Cursor Fix in Web

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.

Support Embeddings APIs in Langchain

1 participant