Name

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 paramter in update_current_trace:

main.py
1from openai import OpenAI
2from deepeval.tracing import observe, update_current_trace
3
4client = OpenAI()
5
6@observe()
7def llm_app(query: str):
8 update_current_trace(name="Call LLM")
9 return client.chat.completions.create(
10 model="gpt-4o",
11 messages=[{"role": "user", "content": query}]
12 ).choices[0].message.content
13
14llm_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 decorating. If you wish to overwrite this behavior, simply provide a name to the update_current_span function:

main.py
1from openai import OpenAI
2from deepeval.tracing import observe, update_current_span
3
4client = OpenAI()
5
6@observe()
7def llm_app(query: str):
8 update_current_span(name="Call LLM")
9 return client.chat.completions.create(
10 model="gpt-4o",
11 messages=[{"role": "user", "content": query}]
12 ).choices[0].message.content
13
14llm_app("Write me a poem.")