Dropping Traces
Conditionally dropping traces before they are sent to Confident AI
Included on the Enterprise plan. Book a demo, opens in a new tab. Included on the Team plan. Included on the Starter plan. Not included on the Free plan.
Overview
Dropping lets you silently discard a trace based on runtime conditions. Unlike sampling, which randomly drops a percentage of traces, this gives you full programmatic control over which traces are sent.
Drop a Trace
To drop the current trace, call update_current_trace (Python) or updateCurrentTrace (TypeScript) with drop set to True/true. The trace will be silently discarded and never sent to the observatory.
from deepeval.tracing import observe, update_current_trace
from openai import OpenAI
client = OpenAI()
@observe()
def llm_app(query: str):
if "health" in query.lower():
update_current_trace(drop=True)
return "OK"
return client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": query}]
).choices[0].message.content
llm_app("/health") # this trace is dropped
llm_app("Write me a poem.") # this trace is sentimport { observe, updateCurrentTrace } from 'deepeval/tracing';
import OpenAI from 'openai';
const llmApp = async (query: string) => {
if (query.toLowerCase().includes("health")) {
updateCurrentTrace({ drop: true });
return "OK";
}
const openai = new OpenAI();
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 });
observedLlmApp("/health"); // This trace is dropped
observedLlmApp("Write me a poem."); // This trace is sentLast updated on