I trace AutoGen with Traceloop. How do I switch to Rius?
Rius traces AutoGen with its own integration, so you replace Traceloop’s init call with rius.init() and wrap your entrypoint in one observe. AutoGen’s own OpenTelemetry spans give you the agent and tool structure, and the openai integration adds each model call with tokens and cost. You remove Traceloop from the process, because running both instrumentations produces duplicate LLM spans. The AutoGen integration page has the full recipe this article builds on.
How it works
- Framework spans. AutoGen emits
create_agent,invoke_agentandexecute_toolspans through the global tracer provider, whichrius.init()installs. Agent and tool structure arrives without wrappers. - Model calls. AutoGen sends them through the OpenAI client (
autogen-ext[openai]), and theopenaiintegration records each one with model, tokens and cost. Rius computes the cost, so you never send it. - One wrapper. A single
observeon your entrypoint groups agent creation and invocation into one trace per unit of work. - One instrumentation per process. Traceloop and the Rius SDK instrument the same client libraries with different instrumentors, so you run one or the other in a process. That is why this switch removes Traceloop instead of layering Rius on top.
The AutoGen integration is for Python. The Migrate to Rius overview covers the other ways to move over from a tool that already emits OpenTelemetry.
Set it up
-
Remove Traceloop from one service’s process first. Leave the others reporting to Traceloop while you compare. Delete the
Traceloop.init()call, and removeTRACELOOP_API_KEYand any otherTRACELOOP_*values from your deployment. Replace the Traceloop decorators on your entrypoint withobserve, as in step 3. -
Install the Rius SDK with the OpenAI instrumentation and AutoGen.
pip install "glassflow-rius[openai]" "autogen-agentchat" "autogen-ext[openai]" -
Initialize Rius and wrap the entrypoint. Your agent, model client and tools stay as they are.
import rius from autogen_agentchat.agents import AssistantAgent from autogen_ext.models.openai import OpenAIChatCompletionClient from rius import SpanKind rius.init(api_key="ri_...", service_name="my-agent") def account_status(email: str) -> str: """Fetch a customer's account standing by email.""" return lookup(email) @rius.observe(name="handle-ticket", kind=SpanKind.AGENT) async def handle_ticket(ticket: str) -> str: agent = AssistantAgent( name="support_agent", model_client=OpenAIChatCompletionClient(model="gpt-5-mini"), tools=[account_status], system_message="Answer support questions; check accounts with the tool.", ) result = await agent.run(task=ticket) return str(result.messages[-1].content) -
Remove Traceloop decorators from AutoGen tool functions, and do not replace them with
observe. AutoGen runs tools in a detached context, so anobservewrapper on a tool splits off as its own single-span trace. The framework’sexecute_toolspans already cover your tools. -
Map conversations and users. Replace
@conversationorset_conversation_id(cid)withwith rius.session(cid):around each run, reusing your conversation id. ReplaceTraceloop.set_association_propertiesfor a user withwith rius.user(uid):, which stampsuser.idon every span in scope. -
Verify. Run one request that calls a tool and open the trace in the console. You should see the root span, the
invoke_agentandexecute_toolspans, and the model generation with model, tokens and cost.
The Traceloop migration guide maps every other Traceloop decorator to its Rius equivalent.
What you get
A run that calls a tool looks like this, from a real trace with autogen-agentchat 0.7.5:
handle-ticket AGENT 2.8s
├─ create_agent support_agent 0ms
└─ invoke_agent support_agent 2.8s
├─ ChatCompletion LLM 2.6s
└─ execute_tool account_status 0ms- Agent and tool structure from AutoGen’s own spans, under one root span per unit of work.
- Model calls as generations with model, token counts and cost. Cost is a list-price estimate in US dollars.
- Sessions from
rius.session(), so one conversation groups its traces together. - Different span names. Rius names spans by the GenAI conventions, such as
invoke_agent <name>andexecute_tool <name>, where OpenLLMetry used<name>.agentand<name>.tool. Update any saved searches that match on span names. - Known quirks. Framework spans arrive with status UNSET rather than OK on success, though the trace status still reads Ok, and generation spans are all named
ChatCompletion.
When something else fits
- If you prefer to keep OpenLLMetry, you can instead change where it exports, as the Traceloop migration guide describes.
- Traceloop platform features such as monitors, evaluators, guardrails, the prompt registry and datasets have no Rius equivalent, so keep Traceloop for those.
- If you use frameworks other than AutoGen, the Integrations page lists what each one supports.