Commit 5e5487b
authored
fix(node): Prevent duplicate LangChain spans from double module patching (#19684)
The LangChain instrumentation registers both a module-level and a
file-level hook for each provider package (e.g. `@langchain/openai`).
Both hooks call _patch, which wraps the same prototype methods (invoke,
stream, batch) with a new
proxy and callback handler. This results in every LangChain call
producing duplicate gen_ai.chat spans. The fix adds a
`__sentry_patched__` guard on the prototype to skip patching if it's
already been done.
Closes #19685 (added automatically)1 parent f820401 commit 5e5487b
File tree
2 files changed
+23
-0
lines changed- dev-packages/node-integration-tests/suites/tracing/langchain
- packages/node/src/integrations/tracing/langchain
2 files changed
+23
-0
lines changedLines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
172 | 189 | | |
173 | 190 | | |
174 | 191 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
| |||
0 commit comments