Skip to main content

Tracer

Defined in the trace module.
Rust AI Agent SDK Global tracer for convenience.

Fields

NameTypeDescription
tracesArc<RwLock<HashMap<StringActive traces
exportersArc<RwLock<Vec<Box<dyn TraceExporter>>>>Exporters

Methods

new

fn new() -> Self
Create a new tracer.

add_exporter

fn add_exporter(&self, exporter: impl TraceExporter + 'static) -> ()
Add an exporter. Parameters:
NameType
exporterimpl TraceExporter + 'static

start_trace

fn start_trace(&self, name: impl Into<String>) -> String
Start a new trace. Parameters:
NameType
nameimpl Into&lt;String&gt;

end_trace

fn end_trace(&self, trace_id: &str) -> ()
End a trace and export. Parameters:
NameType
trace_id&str

start_span

fn start_span(&self, trace_id: &str, name: impl Into<String>, kind: SpanKind) -> Option<String>
Start a span in a trace. Parameters:
NameType
trace_id&str
nameimpl Into&lt;String&gt;
kindSpanKind

end_span

fn end_span(&self, trace_id: &str, span_id: &str) -> ()
End a span in a trace. Parameters:
NameType
trace_id&str
span_id&str

trace_count

fn trace_count(&self) -> usize
Get trace count.

Source

View on GitHub

praisonai/src/trace/mod.rs at line 382