Trace Sampling
Sending only part of your traces 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
Sampling allows you to control what percentage of traces are sent to Confident's observatory.
Configure Sample Rate
Configure the sampling rate by setting the CONFIDENT_SAMPLE_RATE environment variable, which represents the proportion of traces that will be sent to the observatory.
export CONFIDENT_SAMPLE_RATE=0.5Alternatively, you can set the sampling rate directly in code:
from deepeval.tracing import observe, trace_manager
from openai import OpenAI
client = OpenAI()
trace_manager.configure(sampling_rate=0.5)
@observe()
def llm_app(query: str):
return client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": query}]
).choices[0].message.content
for _ in range(10):
llm_app("Write me a poem.") # roughly half of these traces will be sentimport { observe, traceManager } from 'deepeval/tracing';
import OpenAI from 'openai';
const openai = new OpenAI();
traceManager.configure({ samplingRate: 0.5 });
const llmApp = async (query: string) => {
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});
for (let i = 0; i < 10; i++) {
observedLlmApp("Write me a poem."); // Roughly half of these traces will be sent
}Last updated on