pub struct Trace { /* private fields */ }Expand description
Inference object that provides custom tracing.
Is constructed with TraceHandler object that is activated each time an event occures.
Implementations§
Source§impl Trace
impl Trace
Sourcepub fn new_with_handle<H: TraceHandler, T: TensorTraceHandler>(
parent_id: u64,
activity_handler: Option<H>,
tensor_activity_handler: Option<T>,
) -> Result<Self, Error>
pub fn new_with_handle<H: TraceHandler, T: TensorTraceHandler>( parent_id: u64, activity_handler: Option<H>, tensor_activity_handler: Option<T>, ) -> Result<Self, Error>
Create a new inference trace object.
The activity_handler and tensor_activity_handler will be called to report activity
including Trace::report_activity called by this trace as well as by every child traces that are spawned
by this one. So the TraceHandler::trace_activity and TensorTraceHandler::trace_tensor_activity
should check the trace object (first argument) that are passed to it
to determine specifically what trace was reported.
level: The tracing level.
parent_id: The parent trace id for this trace.
A value of 0 indicates that there is not parent trace.
activity_handler: The callback function where activity (on timeline event)
for the trace (and all the child traces) is reported.
tensor_activity_handler: Optional callback function where activity (on tensor event)
for the trace (and all the child traces) is reported.
Sourcepub fn report_activity<N: AsRef<str>>(
&self,
timestamp: Duration,
activity_name: N,
) -> Result<(), Error>
pub fn report_activity<N: AsRef<str>>( &self, timestamp: Duration, activity_name: N, ) -> Result<(), Error>
Report a trace activity. All the traces reported using this API will be send Activity::CustomActivity type.
timestamp The timestamp associated with the trace activity.
name The trace activity name.
Sourcepub fn id(&self) -> Result<u64, Error>
pub fn id(&self) -> Result<u64, Error>
Get the id associated with the trace. Every trace is assigned an id that is unique across all traces created for a Triton server.
Sourcepub fn parent_id(&self) -> Result<u64, Error>
pub fn parent_id(&self) -> Result<u64, Error>
Get the parent id associated with the trace.
The parent id indicates a parent-child relationship between two traces.
A parent id value of 0 indicates that there is no parent trace.
Sourcepub fn model_name(&self) -> Result<String, Error>
pub fn model_name(&self) -> Result<String, Error>
Get the name of the model associated with the trace.
Sourcepub fn model_version(&self) -> Result<i64, Error>
pub fn model_version(&self) -> Result<i64, Error>
Get the version of the model associated with the trace.
Sourcepub fn request_id(&self) -> Result<String, Error>
pub fn request_id(&self) -> Result<String, Error>
Get the request id associated with a trace. Returns the version of the model associated with the trace.
Sourcepub fn spawn_child(&self) -> Result<Trace, Error>
pub fn spawn_child(&self) -> Result<Trace, Error>
Returns the child trace, spawned from the parent(self) trace.
Be causious: Trace is deleting on drop, so don’t forget to save it. Also do not use parent and child traces for different Requests: it can lead to Seq Faults.
Sourcepub fn set_context(&mut self, context: String) -> Result<&mut Self, Error>
pub fn set_context(&mut self, context: String) -> Result<&mut Self, Error>
Set context to Triton Trace.