The StateGraph instance to instrument
Optionaloptions: LangGraphOptionsOptional configuration for recording inputs/outputs
import { instrumentLangGraph } from '@sentry/cloudflare';
import { StateGraph } from '@langchain/langgraph';
const graph = new StateGraph(MessagesAnnotation)
.addNode('agent', mockLlm)
.addEdge(START, 'agent')
.addEdge('agent', END);
instrumentLangGraph(graph, { recordInputs: true, recordOutputs: true });
const compiled = graph.compile({ name: 'my_agent' });
Directly instruments a StateGraph instance to add tracing spans
This function can be used to manually instrument LangGraph StateGraph instances in environments where automatic instrumentation is not available or desired.