Skip to Content

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

To switch from Traceloop to Rius for LiteLLM, you install the litellm extra, call rius.init, and remove Traceloop.init. Each routed completion then arrives as a span with the model, token usage and cost. The Rius SDK instruments LiteLLM on init, so one extra covers every provider behind the router, and your decorators map to observe wrappers.

How it works

Traceloop’s SDK is OpenLLMetry, which is plain OpenTelemetry. The Rius SDK replaces it with its own LiteLLM integration, which turns on when you call rius.init(). Each completion that LiteLLM routes becomes a span for the model call with the model, token usage and messages. Rius computes the cost from the model and token counts. Costs are list-price estimates in US dollars, and you never send a cost value.

  • One extra covers every provider. LiteLLM puts all providers behind one API, so switching the provider you route to leaves your tracing unchanged.
  • Run one tracer per process. OpenLLMetry and the Rius SDK instrument the same client libraries with different instrumentors, so running both in one process produces duplicate LLM spans. Remove OpenLLMetry in each service where you add Rius.
  • This path is Python only. The LiteLLM integration is Python only, like the LiteLLM library. From TypeScript, calls to a LiteLLM proxy through its OpenAI-compatible endpoint are traced by the OpenAI integration. The model recorded is the one you ask the proxy for.

The Integrations page lists every library and framework the SDK covers. Migrate to Rius compares the ways in from other tools.

Set it up

  1. Install the instrumentation for LiteLLM. The extra installs the instrumentation, not litellm itself, so the package is named here for a fresh environment. A project that already calls LiteLLM has it.

    pip install "glassflow-rius[litellm]" litellm
  2. Replace the Traceloop setup with rius.init. Delete the Traceloop.init(...) call and the TRACELOOP_API_KEY, TRACELOOP_BASE_URL and TRACELOOP_HEADERS values from your deployment. Your LiteLLM calls stay as they are.

    import rius import litellm rius.init(api_key="ri_...", service_name="my-agent") response = litellm.completion( model="gpt-4o-mini", # or any provider LiteLLM routes to messages=[{"role": "user", "content": "hi"}], )

    service_name takes the place of Traceloop’s app_name and names the agent your traces are grouped under.

  3. Swap your OpenLLMetry decorators for observe. A bare observe makes a generic step, so @workflow and @task become @rius.observe(name=...). Agents and tools need a kind, so Rius shows them as agents and tools:

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

    A conversation id from @conversation or set_conversation_id becomes with rius.session(cid):. A user id you set through association properties becomes with rius.user(uid):, which stamps user.id on every span in scope.

  4. Verify one request. Run one completion, then open the trace in the console. The span shows the model, token counts and a cost. Route the same call to another provider and the comparison appears in model analytics.

  5. Move one service at a time while the rest still report to Traceloop. The Traceloop migration guide has the full concept mapping and a cutover checklist.

What you get

  • A span per model call. Each routed completion carries the model, token usage, messages and a server-side cost.
  • Model names without the routing prefix. When the prefix names the provider, openai/gpt-4o-mini lands as gpt-4o-mini with the provider openai. Update any model filters that matched the prefixed form.
  • New span names. Unnamed agent and tool spans are called invoke_agent <name> and execute_tool <name>, where OpenLLMetry used <name>.agent and <name>.tool. Workflow and task spans use their plain names instead of <name>.workflow and <name>.task. Update saved searches that match on span names.
  • Calls counted once. LiteLLM calls OpenAI and OpenAI-compatible providers through the openai client library. If the openai extra is installed too, that client call is traced as a second LLM span under the LiteLLM span. Tokens and cost are still counted once, and the LiteLLM span shows the run’s total. A few setups, such as streamed calls on some instrumentation versions, are still counted twice.
  • Sessions and users. Traces group by session.id and by user.id once you set them with rius.session and rius.user.

When something else fits

  • If you want no code change, keep OpenLLMetry and re-point its exporter at Rius. In Python this switches off Traceloop’s platform client, so get_prompt(), guardrails, feedback, datasets and experiments stop working. The Traceloop migration guide covers that path.
  • Rius has no monitors, evaluators, guardrails, prompt registry, datasets or experiments. If you rely on those, keep Traceloop for them and send traces to both backends through a Collector.
  • If you run LiteLLM as a proxy server, the proxy is a separate process. Instrument the proxy itself or send its OpenTelemetry traces to Rius.

Still stuck? Get help

Last updated on