LangChain
Trace LangChain (and LangGraph) runs with Rius: chains, tools, retrievers, and model calls arrive as a nested trace mirroring your graph.
Setup
Python
pip install "glassflow-rius[langchain]" langchainThe extra installs the instrumentation, not langchain itself, so the
package is named here for a fresh environment. A project that already
calls LangChain has it, and pip leaves it untouched. Without it, init()
logs a DependencyConflict and this integration stays off.
import rius
rius.init(api_key="ri_...", service_name="my-agent")
# build and run your chains exactly as beforeThe integration hooks LangChain’s callback system, so anything that runs through it is traced: LCEL chains, agents, LangGraph nodes.
What gets captured
One span per step, typed by what the step is: chains as CHAIN spans, tool invocations as TOOL, retrievers as RETRIEVER, and model calls as LLM spans with model, token usage, and messages (cost computed server-side). The nesting follows your chain structure, so a trace reads like the execution graph.
Combining with client instrumentation
Installing langchain alongside a client extra (say openai) works:
LangChain’s chat model span wraps the client library’s span, so you get
framework context and client-level detail, nested. Since glassflow-rius
1.1.0 and @glassflow-ai/rius 1.2.0 the SDK makes the chat model span
current during the call, so the client span nests under it; before those
versions the client span started a trace of its own.
Each model call is counted once in tokens and cost, and the LangChain span
still shows the run’s total. Text-completion models (BaseLLM subclasses,
such as langchain_openai.OpenAI) are still counted twice; see
Still counted twice
for that case, the others, and which layer to keep.
Verify
Run one chain that calls a model, then open the trace in the console: you should see the chain’s structure as nested spans, with the LLM leaf carrying model, tokens, and cost.
All step inputs/outputs and messages are content attributes; privacy controls apply to the whole tree.