I trace the OpenAI Agents SDK with Traceloop. How do I switch to Rius?
Rius traces the OpenAI Agents SDK through its openai integration plus observe wrappers, so you replace Traceloop’s setup with rius.init and keep your agent code. Every model call arrives as a generation with tokens and cost. The run and its tools get their shape from the wrappers you add. If you would rather change nothing in code, you can instead keep OpenLLMetry and re-point its exporter, as the Migrate from Traceloop guide describes.
How it works
The OpenAI Agents SDK drives the OpenAI client underneath, so the Rius openai integration captures its model calls with no framework-specific code. The agent loop, tool executions and handoffs run inside the framework, so you wrap your entrypoint and tool bodies with observe to put that structure in the trace. The full integration is on OpenAI Agents SDK, and the list of supported libraries is on Integrations.
The Traceloop decorators map onto observe with a span kind:
@agent(name=...)becomes@rius.observe(kind=SpanKind.AGENT, agent_name=...).@tool(name=...)becomes@rius.observe(kind=SpanKind.TOOL, tool_name=...).@workflowand@taskbecome a plain@rius.observe, which makes a generic step (a CHAIN span).@conversationorset_conversation_idbecomeswith rius.session(cid):.set_association_propertieswith a user id becomeswith rius.user(uid):, which stampsuser.idon every span in scope.
Run one instrumentation layer per process. Rius and OpenLLMetry both instrument the same client libraries, so running both produces duplicate model-call spans. This is part of the broader Migrate to Rius path for tools that emit OpenTelemetry.
Set it up
-
Move one service first and leave the others reporting to Traceloop while you compare. In that service, remove the Traceloop setup. Delete the
Traceloop.init(...)call and the Traceloop decorators, and removeTRACELOOP_API_KEYand any otherTRACELOOP_*values from your deployment. -
Install the Rius SDK with the openai extra, next to the framework. The extra installs the instrumentation, not the library itself.
pip install "glassflow-rius[openai]" openai-agents -
Initialize Rius, turn off the framework’s own tracing, and wrap the entrypoint and tool bodies. Put
@function_tooloutermost andobserveon the function body, because the framework reads the function signature for the tool schema.import rius from agents import Agent, Runner, function_tool, set_tracing_disabled from rius import SpanKind rius.init(api_key="ri_...", service_name="my-agent") set_tracing_disabled(True) @function_tool @rius.observe(kind=SpanKind.TOOL) def account_status(email: str) -> str: """Fetch a customer's account standing by email.""" return lookup(email) support_agent = Agent( name="support_agent", instructions="Answer support questions; check accounts with the tool.", tools=[account_status], model="gpt-5-mini", ) @rius.observe(name="handle-ticket", kind=SpanKind.AGENT) def handle_ticket(ticket: str) -> str: result = Runner.run_sync(support_agent, ticket) return str(result.final_output)set_tracing_disabled(True)makes Rius the single telemetry path. The framework’s built-in tracing uploads to the OpenAI platform, and leaving it on does not interfere with Rius. -
Scope each run with
rius.session(), reusing your conversation or ticket id, so every turn of one conversation groups together. Use underscores in agent names, because hyphens get rewritten in the generated handoff tool name and the framework warns on every run. -
Run one request that calls a tool, then open the trace in the console.
What you get
After the switch, one request looks like this in the trace tree:
handle-ticket AGENT 9.8s
├─ Response LLM 2.3s triage decides to hand off
├─ Response LLM 2.8s billing agent decides to call the tool
├─ execute_tool account_status TOOL 0ms
└─ Response LLM 4.6s billing agent answers- The root span is your
observewrapper, shown as an agent. - Each model call is a generation with model, tokens, cost and time to first token. Rius computes cost from the model and token counts, as a list-price estimate in US dollars.
- Your tool bodies appear as tool spans with their names.
- Conversations group into sessions through
rius.session(). - Span names follow the GenAI conventions. Unnamed agent and tool spans are called
invoke_agentandexecute_toolfollowed by the name, rather than the name followed by.agentor.tool. Update any saved searches that match on span names.
Three things to know. A handoff produces no span of its own. It shows only as consecutive generations that belong to different agents, so add an observe wrapper per agent entry if the boundary matters. Generation spans are all named Response. Streamed runs carry token counts only when usage is enabled on the underlying OpenAI client, as described on the OpenAI integration page.
When something else fits
- If you want no code changes, keep OpenLLMetry and change its base URL and auth header to point at Rius. In Python, re-pointing also switches off Traceloop platform features such as prompt fetching, guardrails and datasets.
- If you rely on Traceloop monitors, evaluators, a prompt registry or datasets, Rius does not offer them, so keep Traceloop for those and send traces to both through a Collector while you compare.
- Running both backends in parallel during evaluation is supported. Cut over once Rius shows what you need.