Installation
Usage
The LangWatch API key is configured by default via the
LANGWATCH_API_KEY environment variable.@langwatch.trace() decorator creates a parent trace for your graph execution. get_langchain_callback() goes in the config of agent.invoke(), and the same config argument works for ainvoke() and stream(). From there LangGraph passes it down: each node becomes a chain span named after the node, model calls become LLM spans, and tool calls become tool spans.
A callback attached only to the model call inside one node produces LLM spans alone. The tool nodes and the plain function nodes never appear, so the trace does not show which step the graph ran.
Check it worked
Run the example. Then open your project in LangWatch: a new trace named “LangGraph - Calculator Agent” appears in the traces list within a few seconds. Open it to see the graph’s nodes, tool calls and LLM calls nested inside it. If no trace appears, check thatLANGWATCH_API_KEY is set in the environment the script runs in.
Related
- Capturing RAG - Learn how to capture RAG data from LangChain retrievers and tools
- Capturing Metadata and Attributes - Add custom metadata and attributes to your traces and spans
- Capturing Evaluations & Guardrails - Log evaluations and implement guardrails in your LangGraph applications