Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ supported:

<Alert>

For meta-framework applications using all runtimes, you need to manually wrap your compiled graph with `instrumentLangGraph`. See instructions in the [Browser-Side Usage](#browser-side-usage) section.
For meta-framework applications using all runtimes, you need to manually wrap your graph before compiling with `instrumentLangGraph`. See instructions in the [Browser-Side Usage](#browser-side-usage) section.

</Alert>

Expand All @@ -52,7 +52,7 @@ For meta-framework applications using all runtimes, you need to manually wrap yo

_Import name: `Sentry.langGraphIntegration`_

The `langGraphIntegration` adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by automatically wrapping LangGraph operations and recording AI agent interactions including agent invocations, graph executions, and node operations.
The `langGraphIntegration` adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by automatically wrapping LangGraph operations and recording AI agent interactions including agent invocations, graph executions, and node operations.

<PlatformSection notSupported={["javascript.bun", "javascript.cloudflare"]}>

Expand Down Expand Up @@ -98,11 +98,12 @@ For Cloudflare Workers, manual instrumentation is required using `instrumentLang

</PlatformSection>

The `instrumentLangGraph` helper adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by wrapping a compiled LangGraph graph and recording AI agent interactions with configurable input/output recording. You need to manually wrap your compiled graph with this helper. See example below:
The `instrumentLangGraph` helper adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by wrapping a `StateGraph` before compilation and recording AI agent interactions with configurable input/output recording. You need to call this helper on the graph **before** calling `.compile()`. See example below:

```javascript
import { ChatOpenAI } from "@langchain/openai";
import { StateGraph, MessagesAnnotation, START, END } from '@langchain/langgraph';
import { SystemMessage, HumanMessage } from '@langchain/core/messages';

// Create LLM call
const llm = new ChatOpenAI({
Expand All @@ -124,14 +125,14 @@ const agent = new StateGraph(MessagesAnnotation)
.addEdge(START, 'agent')
.addEdge('agent', END);

const graph = agent.compile({ name: 'my_agent' });

// Manually instrument the graph
Sentry.instrumentLangGraph(graph, {
// Instrument the graph before compiling
Sentry.instrumentLangGraph(agent, {
recordInputs: true,
recordOutputs: true,
});

const graph = agent.compile({ name: 'my_agent' });

// Invoke the agent
const result = await graph.invoke({
messages: [
Expand Down
Loading