feat(core): Instrument LangGraph Agent#18114
Merged
RulaKhaled merged 5 commits intodevelopfrom Nov 17, 2025
Merged
Conversation
1 task
Contributor
size-limit report 📦
|
Contributor
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.
|
nicohrubec
reviewed
Nov 13, 2025
dev-packages/node-integration-tests/suites/tracing/langgraph/scenario-tools.mjs
Show resolved
Hide resolved
dev-packages/node-integration-tests/suites/tracing/langgraph/scenario.mjs
Show resolved
Hide resolved
e45920a to
932f908
Compare
nicohrubec
approved these changes
Nov 17, 2025
| export function extractTokenUsageFromMetadata(span: Span, message: LangChainMessage): void { | ||
| const msg = message as Record<string, unknown>; | ||
|
|
||
| // Extract from usage_metadata (newer format) |
Member
There was a problem hiding this comment.
l: Sure, though I think it would be good then to put that detail in the comment or maybe a link where that is explained (if you have one) so that it is more clear
RulaKhaled
added a commit
that referenced
this pull request
Nov 19, 2025
#18112) This PR adds manual instrumentation support for LangGraph StateGraph operations in Cloudflare Workers and Vercel Edge environments. ``` import * as Sentry from '@sentry/cloudflare'; // or '@sentry/vercel-edge' import { StateGraph, START, END, MessagesAnnotation } from '@langchain/langgraph'; // Create and instrument the graph const graph = new StateGraph(MessagesAnnotation) .addNode('agent', agentFn) .addEdge(START, 'agent') .addEdge('agent', END); Sentry.instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true, }); const compiled = graph.compile({ name: 'weather_assistant' }); await compiled.invoke({ messages: [{ role: 'user', content: 'What is the weather in SF?' }], }); ``` - [x] This PR depends on #18114
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds official support for instrumenting LangGraph StateGraph operations in Node with Sentry tracing, following OpenTelemetry semantic conventions for Generative AI.
Currently supported:
Node.js - Both agent creation and invocation are instrumented in this PR
ESM and CJS - Both module systems are supported
The langGraphIntegration() accepts the following options:
e.g
Operations traced: