I trace the OpenAI API with Traceloop. How do I switch to Rius?
Rius replaces your Traceloop setup for OpenAI with one init call, and each OpenAI call arrives as a span with model, tokens and cost. Install the OpenAI extra of the Rius SDK, swap Traceloop.init for rius.init, and remove OpenLLMetry from the process. If you would rather change no code, keep OpenLLMetry and re-point its exporter at Rius, as the Traceloop migration guide describes.
How it works
Traceloop’s SDK is OpenLLMetry, which instruments the OpenAI client and exports OpenTelemetry traces. The Rius SDK does the same job with its own OpenAI instrumentation. When you call init(), Rius detects the installed integration and instruments the OpenAI client for the whole process, so every call is traced without touching your call sites. The OpenAI integration page covers it in full, and the integrations overview lists the other libraries and frameworks.
Both tools instrument the same client library, so run one or the other in a process. Running both produces duplicate LLM spans.
The OpenLLMetry decorators map onto observe:
@workflowand@taskbecome@rius.observe, which makes a generic step (the default kind is CHAIN).@agentbecomes@rius.observe(kind=SpanKind.AGENT, agent_name=...).@toolbecomes@rius.observe(kind=SpanKind.TOOL, tool_name=...).@conversationandset_conversation_idbecomewith rius.session(cid):.set_association_propertieswith a user id becomeswith rius.user(uid):, which setsuser.idon every span in scope.
Set it up
-
Create a Rius API key if you do not have one, and pick one service to move first. The other services keep reporting to Traceloop, so you can compare the two backends on similar traffic. In the service you move, remove the Traceloop SDK, its
Traceloop.initcall andTRACELOOP_API_KEY. -
Install the Rius instrumentation for OpenAI. The extra does not install
openaiitself, so a fresh environment names it too:pip install "glassflow-rius[openai]" openai -
Initialize Rius where you initialized Traceloop.
app_namebecomesservice_name, which names the agent your traces are grouped under. Keep using the OpenAI client exactly as before:import rius from openai import OpenAI rius.init(api_key="ri_...", service_name="my-agent") client = OpenAI() # use the client exactly as before -
Replace each OpenLLMetry decorator with
observe, using the mapping above. If you use TypeScript,withWorkflow,withAgentandwithToolbecomeobservewrappers with the matching kind, andwithConversationbecomeswithSession. Runnpm install @arizeai/openinference-instrumentation-openai, callinit()before you create the client, and awaitreadyso the patch is in place before your first call:import { init } from '@glassflow-ai/rius' import OpenAI from 'openai' const rius = init({ apiKey: 'ri_...', serviceName: 'my-agent' }) await rius.ready const client = new OpenAI() // use the client exactly as before -
For streamed calls, ask OpenAI to send usage with the final chunk by passing
stream_optionswithinclude_usageset to true. Without it, streamed spans have no token counts and so no cost. -
Update saved searches that match on span names. Unnamed agent and tool spans are called
invoke_agent <name>andexecute_tool <name>, not<name>.agentand<name>.tool, and workflow and task spans use their plain name. -
Run one request and open the trace in the console. Compare trace counts, token totals and cost with the services still on Traceloop for a few days, then move the rest. To send identical traces to both backends instead, keep OpenLLMetry and use the Collector fan-out. The wider path is in Migrate to Rius.
What you get
- A span for each model call. Each chat completion shows the resolved model (for example
gpt-4o-mini-2024-07-18), input and output token counts, and the input and output messages. - Cost per call. Rius computes it on the server from the model and tokens, as a list-price estimate in US dollars. You never send a cost value.
- Errors recorded. A call OpenAI rejects, such as a 404 for an unknown model, a 429 or a timeout, appears as an ERROR span with
error.typenaming the error class. - Time to first token on Python streams. The Python integration records it without manual code. In TypeScript, streamed chat completions carry token usage and cost when you set
include_usage, but no time to first token. - Your structure. Agents and tools appear as agent and tool spans with their names, and conversations appear as sessions.
- Privacy controls.
capture_content=False(captureContent: falsein TypeScript) and masking apply to instrumented calls.
When something else fits
- If you want no code changes, keep OpenLLMetry and change its base URL and auth header to point at Rius. Your decorators keep working.
- If you rely on Traceloop’s monitors, evaluators, guardrails, prompt registry, datasets or experiments, keep Traceloop for those. Rius has no equivalent, so send traces to both while you decide.
- Re-pointing OpenLLMetry in Python switches off Traceloop platform calls such as
get_prompt(), so use a Collector fan-out if your code needs them.