LangGraph
Adds instrumentation for the LangGraph SDK.
Import name: Sentry.langGraphIntegration
The langGraphIntegration adds instrumentation for @langchain/langgraph to capture spans by automatically wrapping LangGraph operations and recording AI agent interactions including agent invocations, graph executions, and node operations.
Enabled by default and automatically captures spans for LangGraph SDK calls. Requires Sentry SDK version 10.28.0 or higher.
To customize what data is captured (such as inputs and outputs), see the Options in the Configuration section.
The following options control what data is captured from LangGraph operations:
Type: boolean (optional)
Records inputs to LangGraph operations (such as messages and state data passed to the graph).
Defaults to true if sendDefaultPii is true.
Type: boolean (optional)
Records outputs from LangGraph operations (such as generated responses, agent outputs, and final state).
Defaults to true if sendDefaultPii is true.
Usage
Using the langGraphIntegration integration:
Sentry.init({
dsn: "____PUBLIC_DSN____",
// Tracing must be enabled for agent monitoring to work
tracesSampleRate: 1.0,
integrations: [
Sentry.langGraphIntegration({
// your options here
}),
],
});
By default, tracing support is added to the following LangGraph SDK calls:
- Agent Creation (
gen_ai.create_agent) - Captures spans when compiling a StateGraph into an executable agent - Agent Invocation (
gen_ai.invoke_agent) - Captures spans for agent execution viainvoke()
@langchain/langgraph:>=0.2.0 <2.0.0
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").