Update your Python SDK to version 2.0 for enhanced stability and easier integration. Learn more

This page goes over some advanced tracing features.

Adding a trace name

If you’re tracing multiple functions, you can use the name parameter to distinguish between them:

Currently, when using python sdk, you can name a trace only when using baserun.start_trace context manager and it’s not possible to do so when using @baserun.trace decorator.

Setting a trace’s result

By default a trace’s result value will be the return value of the function or context that is traced. If you want to be more explicit, you can set the result value of a trace.

Adding custom metadata

You can also add custom metadata. This metadata could be whatever you like, provided that it is JSON serializable. For instance, you may want to include references to other objects or systems.

Associating with an LLM request

By default, annotations such as logs and checks are associated with a trace as a whole. To associate a with particular LLM request, you simply need to pass the completion ID from your LLM request. To do so using OpenAI’s SDK, you can do the following:

Here is how the user feedback will look like in Baserun dashboard:

Example