Tracing

Concepts

Runs, spans, conversations and users: what each one is in Trodo, which IDs tie them together, and what is added up for you.

Runs and spans

One execution of your agent is a run: one wrapAgent call, one request answered, one job done. Every step inside it is a span, and spans nest under the run and under each other. The run plus its span tree is the trace:

runsupport-agent3.3k tokens · $0.016 · 2.1s
llmopenai.chat.completions1.2k tokens · $0.004 · 840ms
toollookup_order120ms
retrievalvector_search60ms
llmopenai.chat.completions2.1k tokens · $0.012 · 1.1s

A run has a name (the agent's name), an input, an output and a status. You set those; everything else on the run is added up from its spans.

A span's kind decides what it shows and what it adds to the run:

KindForAdds to the run
llmA model callTokens and cost
toolA function the agent callsTool count
retrievalA vector search or document lookup
agentA sub-agent or a stage of the run
genericAny other step you want timed

Model calls from supported SDKs and frameworks become llm spans on their own. You add the rest with manual spans.

What is added up

On the runComes from
Tokens in and outEvery llm span under the run
CostEach llm span's model and tokens, priced by Model prices
DurationThe run's start and end; each span keeps its own
Spans, tools, errorsCounts of the spans under the run, and of those that failed (Status & errors)

So the run's totals always match the spans that explain them.

Users and conversations

Two IDs you pass on the wrap turn a stream of runs into something you can read per person and per chat:

  • distinctId is the user the run was for. It joins runs to the user's profile, filters, and the Users page. Without it, each run's user is an anonymous id. See Users.
  • conversationId groups the runs of one multi-turn chat or thread. Each turn is still its own run with its own trace; the conversation stacks them in order. Conversation-level evals score the whole thread. See Conversations.

Where you see them

Traces has three views, from widest to narrowest: Conversations, Runs and Spans. Each conversation holds runs, and each run holds spans. Open any row to see its trace.

Traces with the Conversations, Runs and Spans views: one row per run with its duration, user, tokens, cost, errors, agent, span count and conversation.

Run IDs

Every run has a run ID, a UUID. wrapAgent returns it (Python: run.run_id); use it to send feedback, to find the run in Traces, or to log next to your own request IDs.

const { result, runId } = await trodo.wrapAgent('support-agent', async (run) => { /* ... */ });
with trodo.wrap_agent("support-agent") as run:
    ...
run_id = run.run_id

To give a run an ID of your own, for example so a job's ID finds its trace, pass runId to startRun. It must be a UUID. Turn your own ID into one that is always the same for the same job:

import { v5 as uuidv5 } from 'uuid';

const runId = uuidv5(`job:${job.id}`, uuidv5.URL);
await trodo.startRun('nightly-ingest', { runId });
import uuid

run_id = str(uuid.uuid5(uuid.NAMESPACE_URL, f"job:{job.id}"))
trodo.start_run("nightly-ingest", run_id=run_id)

When a run crosses services, its ID travels on a header and downstream spans join the same run. See Distributed tracing.

On this page