Skip to Content

I trace LangChain with Traceloop. How do I switch to Rius?

Rius replaces Traceloop’s LangChain tracing once you remove OpenLLMetry and install the Rius SDK with its langchain extra. One call to init() then traces your chains, tools, retrievers and model calls as a single nested trace, with cost computed by Rius. Your chain code does not change. If you prefer to keep OpenLLMetry, you can instead re-point its exporter at Rius.

How it works

Traceloop’s SDK is OpenLLMetry, which instruments LangChain and exports OpenTelemetry traces. The Rius LangChain integration works differently: it hooks LangChain’s callback system, so anything that runs through it is traced, including LCEL chains, agents and LangGraph nodes. It is available in Python and TypeScript.

Each step becomes one span, typed by what the step is:

  • Chains are CHAIN spans.
  • Tool invocations are TOOL spans.
  • Retrievers are RETRIEVER spans.
  • Model calls are LLM spans with the model, token usage and messages.

The nesting follows your chain structure, so the trace reads like your execution graph.

OpenLLMetry and the Rius SDK instrument the same client libraries with different instrumentors. If both run in one process, you get duplicate LLM spans. Run one or the other per process, so remove OpenLLMetry in the same change that adds Rius.

If you also install a client extra such as openai, LangChain’s chat model span wraps the client library’s span, so you see framework context and client detail, nested. Each model call is counted once in tokens and cost. Text-completion models (BaseLLM subclasses such as langchain_openai.OpenAI) are still counted twice.

Set it up

  1. Move one service first and leave the others reporting to Traceloop while you compare. Remove OpenLLMetry from that service’s process. Delete the Traceloop.init() call (or traceloop.initialize() in TypeScript) and your TRACELOOP_* settings, so only one instrumentor patches your libraries.

  2. Install the Rius instrumentation for LangChain. The extra installs the instrumentation, not langchain itself, so name the package for a fresh environment:

    pip install "glassflow-rius[langchain]" langchain
  3. Call init() where you called Traceloop.init(). The old app_name becomes service_name, which names the agent your traces are grouped under in Rius. Then build and run your chains exactly as before:

    import rius rius.init(api_key="ri_...", service_name="my-agent") # build and run your chains exactly as before

    In TypeScript, install the instrumentation package, then call init() and wait for ready before your first call. The integration also needs @langchain/core, which a LangChain.js application already has:

    npm install @arizeai/openinference-instrumentation-langchain
    import { init } from '@glassflow-ai/rius' const rius = init({ apiKey: 'ri_...', serviceName: 'my-agent' }) await rius.ready // resolves with the integrations that attached // build and run your chains exactly as before
  4. Replace any Traceloop decorators or helpers you added around your own code. A bare observe makes a CHAIN span, which matches @workflow and @task. For agents and tools, pass a kind:

    import rius from rius import SpanKind @rius.observe(kind=SpanKind.TOOL, tool_name="lookup_weather") def lookup_weather(city: str) -> str: ...

    Use kind=SpanKind.AGENT, agent_name="weather_agent" for @agent. Replace @conversation and set_conversation_id with with rius.session(cid):, and association properties such as user_id with with rius.user(uid):. In TypeScript, withConversation becomes withSession, and the other with... helpers become observe wrappers with the matching kind.

  5. Run one chain that calls a model and open the trace in the console. You should see the chain as nested spans, with the model-call span carrying model, tokens and cost.

The Traceloop migration guide has the full mapping, and Migrate to Rius covers the other tools.

What you get

  • A nested trace that mirrors your graph. Chains, tools, retrievers and model calls each get their own span, and the model-call span shows model, token usage and messages.
  • Cost on every model call. Rius computes it from the model and token counts. Costs are list-price estimates in US dollars, not billed amounts, so you never send a cost value.
  • Sessions and users. rius.session groups traces into sessions, and rius.user stamps user.id on every span in scope. Traceloop’s association properties are not read as Rius users, so set user.id this way.
  • Different span names. Rius names agent spans with invoke_agent followed by the agent name and tool spans with execute_tool followed by the tool name. OpenLLMetry used the name followed by .agent or .tool. Update any saved searches that match on span names.
  • Content stays under your control. Step inputs, outputs and messages are content, and the SDK’s privacy controls apply to the whole tree.

The Integrations page lists the other frameworks and clients the SDK instruments the same way.

When something else fits

  • Keep OpenLLMetry and change only where it sends traces. This is a configuration change, and your decorators keep working. In Python it switches off Traceloop’s platform client, so get_prompt(), guardrails, feedback, datasets and experiments stop working. The Traceloop migration guide covers this path and a Collector setup that sends to both backends while you compare.
  • Keep Traceloop for what Rius does not offer. Rius has no evaluators, guardrails, prompt registry, datasets, experiments or gateway, and existing traces stay in Traceloop. If you depend on those, send traces to both and cut over only when Rius shows what you need.

Still stuck? Get help

Last updated on