|
| 1 | +--- |
| 2 | +title: LangGraph |
| 3 | +description: "Adds instrumentation for LangGraph." |
| 4 | +supported: |
| 5 | + - javascript.node |
| 6 | + - javascript.aws-lambda |
| 7 | + - javascript.azure-functions |
| 8 | + - javascript.connect |
| 9 | + - javascript.express |
| 10 | + - javascript.fastify |
| 11 | + - javascript.gcp-functions |
| 12 | + - javascript.hapi |
| 13 | + - javascript.hono |
| 14 | + - javascript.koa |
| 15 | + - javascript.nestjs |
| 16 | + - javascript.electron |
| 17 | + - javascript.nextjs |
| 18 | + - javascript.nuxt |
| 19 | + - javascript.solidstart |
| 20 | + - javascript.sveltekit |
| 21 | + - javascript.react-router |
| 22 | + - javascript.remix |
| 23 | + - javascript.astro |
| 24 | + - javascript.bun |
| 25 | + - javascript.tanstackstart-react |
| 26 | + - javascript.cloudflare |
| 27 | +--- |
| 28 | + |
| 29 | +<Alert> |
| 30 | + |
| 31 | +This integration requires SDK version `10.25.0` or higher. |
| 32 | + |
| 33 | +</Alert> |
| 34 | + |
| 35 | +_Import name: `Sentry.langChainIntegration`_ |
| 36 | + |
| 37 | +LangGraph is instrumented via the [`langChainIntegration`](./langchain), which automatically captures spans for LangGraph operations including agent invocations, graph executions, and node operations. |
| 38 | + |
| 39 | +## Usage Example |
| 40 | + |
| 41 | +```javascript |
| 42 | +import { ChatOpenAI } from "@langchain/openai"; |
| 43 | +import { createReactAgent } from "@langchain/langgraph/prebuilt"; |
| 44 | +import { HumanMessage, SystemMessage } from "@langchain/core/messages"; |
| 45 | + |
| 46 | +// Create LLM and agent |
| 47 | +const llm = new ChatOpenAI({ |
| 48 | + modelName: "gpt-4o", |
| 49 | + apiKey: process.env.OPENAI_API_KEY, |
| 50 | +}); |
| 51 | + |
| 52 | +const agent = createReactAgent({ llm, tools: [] }); |
| 53 | + |
| 54 | +// Invoke the agent - automatically instrumented |
| 55 | +const result = await agent.invoke({ |
| 56 | + messages: [ |
| 57 | + new SystemMessage("You are a helpful assistant."), |
| 58 | + new HumanMessage("Hello!"), |
| 59 | + ], |
| 60 | +}); |
| 61 | +``` |
| 62 | + |
| 63 | +## Configuration |
| 64 | + |
| 65 | +For configuration options, runtime-specific setup, and detailed information, see the [LangChain integration documentation](/platforms/javascript/guides/node/configuration/integrations/langchain/). |
| 66 | + |
| 67 | +## Supported Versions |
| 68 | + |
| 69 | +- `@langchain/langgraph`: `>=0.2.0 <1.0.0` |
0 commit comments