Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
TraceContext
Defined in the trace module.
Rust AI Agent SDK
Context for a trace.
Fields
| Name | Type | Description |
|---|
id | String | Trace ID |
name | String | Trace name |
start_time | Instant | Start time |
spans | Vec<Span> | All spans |
span_stack | Vec<String> | Current span stack |
attributes | HashMap<String | Attributes |
serde_json | :Value> | Attributes |
Methods
new
fn new(name: impl Into<String>) -> Self
Create a new trace context.
Parameters:
| Name | Type |
|---|
name | impl Into<String> |
elapsed
fn elapsed(&self) -> Duration
Get elapsed time since trace start.
start_span
fn start_span(&mut self, name: impl Into<String>, kind: SpanKind) -> String
Start a new span.
Parameters:
| Name | Type |
|---|
name | impl Into<String> |
kind | SpanKind |
end_span
fn end_span(&mut self, span_id: &str) -> ()
End a span.
Parameters:
current_span_id
fn current_span_id(&self) -> Option<&str>
Get current span ID.
get_span
fn get_span(&self, span_id: &str) -> Option<&Span>
Get a span by ID.
Parameters:
get_span_mut
fn get_span_mut(&mut self, span_id: &str) -> Option<&mut Span>
Get mutable span by ID.
Parameters:
add_event
fn add_event(&mut self, name: impl Into<String>) -> ()
Add event to current span.
Parameters:
| Name | Type |
|---|
name | impl Into<String> |
set_attribute
fn set_attribute(&mut self, key: impl Into<String>, value: impl Serialize) -> ()
Set attribute on current span.
Parameters:
| Name | Type |
|---|
key | impl Into<String> |
value | impl Serialize |
spans
fn spans(&self) -> &[Span]
Get all spans.
span_count
fn span_count(&self) -> usize
Get span count.
Source
View on GitHub
praisonai/src/trace/mod.rs at line 207