How do I switch from Traceloop to Rius for Pydantic AI tracing?
Rius replaces Traceloop for Pydantic AI with the glassflow-rius SDK: call rius.init(), turn on Agent.instrument_all(True), and remove OpenLLMetry. Pydantic AI emits its own OpenTelemetry spans, so agent runs, model requests and tool calls arrive with names, tokens and cost and no wrappers. If you would rather change no code, you can instead keep OpenLLMetry and re-point its exporter at Rius.
How it works
Pydantic AI is OpenTelemetry-native. rius.init() installs the global OpenTelemetry tracer provider, and Agent.instrument_all(True) tells Pydantic AI to emit its spans through it. The framework supplies the run root, the model-call spans and the tool spans. Rius reads their OpenTelemetry GenAI attributes and computes cost on the server. No auto-instrumentation extra is involved.
This is the Rius SDK path of the Traceloop migration guide. The other path keeps OpenLLMetry and changes only where it exports. You set TRACELOOP_BASE_URL to https://ingest.eu.console.rius-glassflow.com, put your Rius key in TRACELOOP_HEADERS as an Authorization=Bearer%20... pair, and set TRACELOOP_METRICS_ENABLED to false in Python, because Rius ingests traces only. Choose the SDK path when you want Pydantic AI’s own span names, Rius session and user scopes, the SDK’s privacy controls and partial spans for long runs.
Run only one of the two per process. OpenLLMetry and the Rius SDK instrument the same client libraries with different instrumentors, so running both duplicates LLM spans.
Set it up
-
Remove the Traceloop setup from one service first. Leave the others reporting to Traceloop while you compare. Delete the
Traceloop.init(...)call and theTRACELOOP_*variables from your deployment, includingTRACELOOP_API_KEY. -
Install the SDK. Pydantic AI needs no extra, so the base package is enough.
pip install glassflow-rius pydantic-ai -
Initialize Rius and turn on Pydantic AI instrumentation. Pass your key, or set
RIUS_API_KEY.service_nameis the agent name Rius groups your traces under. Your agent and tool code stays as it is.import rius from pydantic_ai import Agent rius.init(api_key="ri_...", service_name="my-agent") Agent.instrument_all(True) support_agent = Agent( "openai:gpt-5-mini", instructions="Answer support questions; check accounts with the tool.", ) @support_agent.tool_plain def account_status(email: str) -> str: """Fetch a customer's account standing by email.""" return lookup(email) with rius.session(conversation_id): result = support_agent.run_sync(ticket) -
Map the Traceloop calls you used in your own code.
@workflowand@taskbecome@rius.observe(name=...), which makes a generic CHAIN span.@conversationandset_conversation_idbecomewith rius.session(cid):.Traceloop.set_association_properties({"user_id": uid})becomeswith rius.user(uid):, which stampsuser.idon every span in scope.@agentand@tooldecorators around Pydantic AI agents and tools are not needed, because the framework already emits those spans.
-
Verify. Run one request that calls a tool, then open the trace in the console. You should see the
invoke_agentroot,chatspans with model, tokens and cost, andexecute_toolspans. For other frameworks and libraries, see Integrations, and for this setup in full, see the Pydantic AI integration page.
What you get
Each Pydantic AI concept maps to a span:
| In Pydantic AI | In the Rius trace |
|---|---|
| An agent run | The root span, named invoke_agent plus your agent’s name |
| A model request | A generation named chat plus the model, with tokens and cost |
| A tool call | A span named execute_tool plus the tool’s name |
A run that calls one tool looks like this:
invoke_agent support_agent 6.0s
├─ chat gpt-5-mini 3.3s decides to call the tool
├─ execute_tool account_status 0ms
└─ chat gpt-5-mini 2.7s answers- Names follow the GenAI conventions. Spans are named after your agents, models and tools. Update any saved searches that matched OpenLLMetry’s
<name>.agentstyle names. - Cost is computed by Rius. You never send it. Costs are list-price estimates in US dollars.
- Time to first token and reasoning tokens show up for Pydantic AI runs with
glassflow-rius1.0.1 and 1.0.2 or later, respectively. - Sessions come from
rius.session(). The framework’s spans inherit the scope. - Two quirks. Successful spans arrive with status UNSET, while the trace status still reads Ok. What prompts, completions and tool arguments the spans carry is controlled by Pydantic AI’s
InstrumentationSettings(for exampleinclude_content), on top of the SDK’s privacy controls.
The Migrate to Rius guide covers cutover. Send the same traces to both backends while you compare, and switch only when Rius shows what you need.
When something else fits
- If you rely on Traceloop platform features such as guardrails,
get_prompt(), datasets, experiments or evaluators, keep them in Traceloop. Rius has no equivalent for them, so keep Traceloop for those pieces and add Rius through an OpenTelemetry Collector that sends spans to both. - If you want no code changes at all, keep OpenLLMetry and re-point its exporter, as the Traceloop migration guide describes.
- Existing traces stay in Traceloop. Rius starts from the first span you send it.