Installation
Quick Start
What Gets Traced
The LangChain integration automatically captures:- LLM calls — model name, input messages, output text, token usage (prompt/completion/total), finish reason
- Tool calls — tool name, input arguments, output, duration (via
interaction.track_tool()spans) - Chains — chain execution with nested spans
- Retrievers — query text and document count
- Agent actions — tool selection and execution
- Errors — captured with error status on the span
- Tags and metadata — LangChain tags and metadata are forwarded to Raindrop event properties
- Extended token categories — cached tokens (
ai.usage.cached_tokens) and reasoning tokens (ai.usage.thoughts_tokens) when available from the provider (e.g. OpenAI) - Finish reason — captured as
ai.finish_reasonin event properties (e.g."stop","length")
Configuration
Event name
Every event this integration ships carries an event name (theevent field in
the dashboard). It defaults to ai_generation. Set eventName (event_name in
Python) to label LangChain traffic — e.g. distinguish a support agent from a
billing agent:
Projects
Route events to a specific project by passing its slug asprojectId (project_id in Python):
X-Raindrop-Project-Id header on every event. Omit it (or pass "default") to use your org’s default Production project, which is the existing behavior. Single-project orgs need nothing new.
Multiple projects in one process
Available inraindrop-ai>=0.0.56. When one service runs several LangChain
agents that should report to different projects, create one
RaindropLangchain wrapper per project. Each wrapper owns its own
raindrop.Raindrop client, so the two route independently — there is no shared
module-level state:
raindrop.Raindrop yourself and pass it via client=:
Using with LangGraph
The Raindrop handler works with LangGraph out of the box. It automatically filters LangGraph-internal chain events (graph executor,__start__, __end__, channel nodes)
and deduplicates LLM callbacks that LangGraph may fire multiple times.
Pass the handler both at graph invocation time and inside your LLM node:
LangGraph Best Practices
- Pass callbacks to the model, not the graph — use
callbacks: [raindrop.handler]inside your LLM node function only. Do NOT pass callbacks tograph.invoke()— LangGraph’s internal callback propagation causes duplicate events and noisy chain spans when callbacks are on the graph level. - Create a new handler per request in server environments to avoid state collisions between concurrent graph executions.
- LangGraph-internal filtering is on by default — the
filterLangGraphInternalsoption (default:true) skips noisy internal chain events from the graph executor and node wrappers. Set tofalseif you want full visibility into LangGraph internals.
Using with LangSmith
Raindrop and LangSmith can coexist — both use LangChain’s callback system and receive the same events independently. There is no conflict, but you should be aware of the following:- Both tracers are active simultaneously when
LANGSMITH_TRACING=trueis set. Each builds its own trace tree from the same callback events. This is safe but means LLM calls are traced twice (once by each system). - To use Raindrop only, disable LangSmith tracing:
- To use both, no changes needed. Both handlers receive callbacks and ship data independently. Raindrop traces appear in the Raindrop dashboard; LangSmith traces appear in LangSmith.
- Performance: having two tracers adds minimal overhead since both operate asynchronously and don’t block the LLM pipeline.
Usage with Chains
The same handler works with plain LangChain chains:Passing Tags and Metadata
LangChain tags and metadata are forwarded to Raindrop event properties:Identify Users
Associate events with a user identity after initialization:Track Signals
Send feedback, edits, or custom signals tied to a specific event:Flushing and Shutdown
Always callflush() before your process exits to ensure all telemetry is shipped: