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:
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.")import OpenAI from 'openai';
import { observe, updateCurrentTrace } from 'deepeval/tracing';
const openai = new OpenAI();
const llmApp = async (query: string) => {
updateCurrentTrace({ name: "Call LLM" });
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: query }]
})
return response.choices[0].message.content;
};
const observedLlmApp = observe({fn: llmApp});
await observedLlmApp("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:
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.")import OpenAI from 'openai';
import { observe, updateCurrentSpan } from 'deepeval/tracing';
const openai = new OpenAI();
const llmApp = async (query: string) => {
updateCurrentSpan({ name: "Call LLM" });
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: query }]
})
return response.choices[0].message.content;
};
const observedLlmApp = observe({fn: llmApp});
await observedLlmApp("Write me a poem.");Last updated on