Skip to main content

Installation

Setup

We recommend using UUIDs for session_id and user_id so traces can be grouped reliably across runs.

Usage

Pass the handler via LangChain’s config["callbacks"]:
Unlike other integrations, LangGraph does not use the instrument() pattern. You must pass the handler in config for each invocation.

What gets traced

Token usage

Token usage is extracted from LangChain’s usage_metadata (primary) or legacy llm_output.token_usage (fallback). The mapping is: input_tokensprompt_tokens, output_tokenscompletion_tokens. Reasoning tokens are subtracted from output_tokens when present.

Example with tools

This example builds a ReAct agent using LangGraph with two tools. We trace the agent via LangGraphCallbackHandler:
This produces a trace with: CHAIN (root) → LLM (model call) → TOOL (get_weather) → TOOL (get_population) → LLM (final response).