Uh oh!
There was an error while loading. Please reload this page.
feat(core): Support embeddings in langchain - #20017
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Deps
Other
Bug Fixes 🐛
Internal Changes 🔧Core
Deps
Other
🤖 This preview updates automatically when you update the PR. |
size-limit report 📦
|
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.
|
| /** | ||
| * The span operation for embeddings | ||
| */ | ||
| export const GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE = 'gen_ai.embeddings'; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
I am aware, the others will be cleaned up in a follow up to keep this focused
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Uh oh!
There was an error while loading. Please reload this page.
| }; | ||
| attributes[GEN_AI_SYSTEM_ATTRIBUTE] = inferSystemFromInstance(embeddingsInstance); | ||
| if ('dimensions' in embeddingsInstance) |
There was a problem hiding this comment.
m: Let's generally stick to bracketed ifs in our code, less potential to introduce bugs.
… tests (#125) Embedding support in langchain is added through a separate API Sentry.instrumentLangChainEmbeddings(). As usual this gets auto-instrumented in node and other runtimes need to wrap manually. Updating the templates to use the correct API. PR that implements support in the JS SDK is here: getsentry/sentry-javascript#20017 As in google-genai we don't get any information about token usage for this so skipping the checks.
Uh oh!
There was an error while loading. Please reload this page.


Adds embeddings instrumentation for LangChain (
embedQuery,embedDocuments). LangChain'sEmbeddingsbase 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:
Creates
gen_ai.embeddingsspans. Token usage is not available since LangChain's embedding methods only return raw vectors.Closes#19774