Launch Week 02 wrapped — explore all five launches

Customize Trace Names

Giving names to your traces for better visbility on Confident AI

Overview

Both traces and spans have names, and you can customize them based on your liking for better UI display.

Set Name on Trace

You can name a trace at runtime by providing the name parameter in the update current trace function:

main.py
from openai import OpenAI 
from deepeval.tracing import observe, update_current_trace

client = OpenAI()

@observe()
def llm_app(query: str):
    update_current_trace(name="Call LLM")
    return client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": query}]
    ).choices[0].message.content

llm_app("Write me a poem.")

By default, the name on a trace is set to None.

Set Name on Span

The default name for a span is the name of the function/method you're observing. If you wish to overwrite this behavior, simply provide a name to the update current span function:

main.py
from openai import OpenAI 
from deepeval.tracing import observe, update_current_span

client = OpenAI()

@observe()
def llm_app(query: str):
    update_current_span(name="Call LLM")
    return client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": query}]
    ).choices[0].message.content

llm_app("Write me a poem.")
Ready to monitor AI in production?Connect traces, alerts, dashboards, and evals in one production workflowBook a demo

Last updated on

Built byConfident AI