Tracing

What is Tracing?

Tracing is essentially logging, but where related or subsequent logs is associated with eachother so it is possible to look at them as a whole.

Why Tracing?

This drastically simplifies debugging and understanding complex interactions in chatbot sessions, agent runs or similar.

With the Opper Python and Typescript SDK, you can:

  • Connect related operations together in a trace to see the full flow of a session, agent run or chain.
  • Store feedback, results from evaluations and other data relevant for understanding the quality of the session with metrics.
  • Add contextual information such as user id, session id, agent id etc as metadata.

Calls automatically create spans

When doing calls, the SDK will automatically create a span:

Adding a Span to a Trace

In the following example we will connect a call span to a higher level span.

Adding Metrics to a Span

You can also add metrics to spans. This is useful for evaluating the quality of the session, agent run or similar.

In the following example we will evaluate if the answer is one word and save the verdict as a metric on the span.

Investigate Traces

Traces show up in the portal https://platform.opper.ai/traces. There you can see all traces for your project, including token use, evaluations etc.

List of Traces

Viewing a trace

Click on a trace to view all calls in a trace. Under each call is a generation where you can see the prompt, model used etc.

More information

See more extensive examples in our Python and Node.js SDKs, who both have an example folder with runnable examples.