Title: `instrumentLangGraph` does not instrument `stream()`, only `invoke()` · Issue #19626 · getsentry/sentry-javascript · GitHub
Open Graph Title: `instrumentLangGraph` does not instrument `stream()`, only `invoke()` · Issue #19626 · getsentry/sentry-javascript
X Title: `instrumentLangGraph` does not instrument `stream()`, only `invoke()` · Issue #19626 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/19626
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`instrumentLangGraph` does not instrument `stream()`, only `invoke()`","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/browser\n\n### SDK Version\n\n^10.40.0\n\n### Framework Version\n\n_No response_\n\n### Link to Sentry event\n\nhttps://pri-dogfooding-ai.sentry.io/insights/ai-agents/?project=4510951776059472&statsPeriod=30d&query=trace:[990f076070fd4e64b8d9032e10f0f27c,34466beafe8a4f39a4ba82da51559827]\n\n### Reproduction Example/SDK Setup\n\n_No response_\n\n### Steps to Reproduce\n\n```js\nconst graph = new StateGraph(MyAnnotation)\n .addNode(\"step1\", stepFn)\n .addEdge(START, \"step1\")\n .addEdge(\"step1\", END);\n\nSentry.instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });\nconst compiled = graph.compile({ name: \"my_agent\" });\n\n// Using invoke() — works, produces invoke_agent span\nconst result = await compiled.invoke({ input: \"test\" });\n\n// Using stream() — no invoke_agent span created\nconst stream = await compiled.stream({ input: \"test\" });\nfor await (const chunk of stream) { /* ... */ }\n```\n\n### Expected Result\n\nBoth `invoke()` and `stream()` should produce a parent span wrapping the graph execution.\n\n### Actual Result\n\n\n| Method | `create_agent` span | Agent execution span |\n|--------|---------------------|----------------------|\n| `invoke()` | Yes (0.5ms) | Yes — `gen_ai.invoke_agent` (wraps full execution) |\n| `stream()` | Yes (0.5ms) | **None** |\n\nWith `stream()`, only the `create_agent` span (from `compile()`) appears. The actual graph execution has no parent span. If `createLangChainCallbackHandler` is also used, its child spans become orphaned root transactions instead of nesting under a parent.\n\nNote: The SDK currently defines only `gen_ai.invoke_agent` as the agent-level operation (via `GEN_AI_INVOKE_AGENT_OPERATION_ATTRIBUTE`). There is no `stream_agent` equivalent. Whether `stream()` should reuse `invoke_agent` or get its own operation name is a design decision.\n\n### Additional Context\n\n`instrumentStateGraphCompile` only patches `invoke()`:\n\n```js\nconst originalInvoke = compiledGraph.invoke;\nif (originalInvoke && typeof originalInvoke === 'function') {\n compiledGraph.invoke = instrumentCompiledGraphInvoke(...);\n}\n// stream() is never patched\n```\n\n### Priority\n\n\u003csub>React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>","author":{"url":"https://github.com/priscilawebdev","@type":"Person","name":"priscilawebdev"},"datePublished":"2026-03-04T10:56:18Z","url":"https://github.com/getsentry/sentry-javascript/issues/19626"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4feb04a9-9db3-c6cd-9e68-f8c3de5eb984 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9808:1F98:245930C:304B07C:6B0441CE |
| html-safe-nonce | b18f5eb60e4f3dea5e419531984b331d152d66171331f8a458e9d2ee5de47d10 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODA4OjFGOTg6MjQ1OTMwQzozMDRCMDdDOjZCMDQ0MUNFIiwidmlzaXRvcl9pZCI6Ijc3NjIzODU1MDkyOTI0NTg0NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 589e589dea5b1e0a0870ccde9a5e93ccc2c59999e49080dbdaad3656fc13727b |
| hovercard-subject-tag | issue:4021369180 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/19626/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bf40a8e052350e8840e99e7f590e81d6cf2dbf3360708eca93a2d4524bdf1b63/getsentry/sentry-javascript/issues/19626 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bf40a8e052350e8840e99e7f590e81d6cf2dbf3360708eca93a2d4524bdf1b63/getsentry/sentry-javascript/issues/19626 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | priscilawebdev |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width