fix(node): Use context-scoped suppression for LangChain + AI provider span deduplication#19688
fix(node): Use context-scoped suppression for LangChain + AI provider span deduplication#19688nicohrubec wants to merge 5 commits intodevelopfrom
Conversation
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.
|
There was a problem hiding this comment.
This is great! Can you also please adapt https://github.com/getsentry/sentry-javascript/blob/develop/.agents/skills/add-ai-integration/SKILL.md to mention that lowest-level ai integrations have to check for suppression?
And also, we can add a rule to bugbot to specifically lint for this, see https://github.com/getsentry/sentry-javascript/blob/develop/.cursor/BUGBOT.md#auto-instrumentation-sdk-integrations-sentry-specific-conventions as an example.
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you apply the label |
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Bun
Core
Deno
Deps
Nestjs
Node
Nuxt
Other
Bug Fixes 🐛Ci
Cloudflare
Core
Deps
Hono
Nestjs
Nextjs
Node
Nuxt
Other
Documentation 📚New Release
Other
Internal Changes 🔧Browser
Changelog
Ci
Cloudflare
Core
Deps
Deps Dev
E2e
Lint
Nextjs
Nuxt
Other
Other
🤖 This preview updates automatically when you update the PR. |
When both LangChain and an AI provider integration (OpenAI, Anthropic, Google GenAI) are active, a single LangChain invoke() call produces duplicate gen_ai.chat spans — one from LangChain's callback handler and one from the underlying provider instrumentation.
The previous fix globally disabled provider instrumentations when LangChain was detected, but this broke direct provider SDK calls unrelated to LangChain.
This PR sets a suppression flag on the current scope during LangChain invoke/stream/batch execution. Provider instrumentations check this flag and skip span creation if set.
Closes #19687