pub trait Tracer:
Send
+ Sync
+ Debug {
// Required methods
fn start_span(
&self,
name: Cow<'static, str>,
kind: SpanKind,
attributes: Vec<Attribute>,
) -> Arc<dyn Span>;
fn start_span_with_parent(
&self,
name: Cow<'static, str>,
kind: SpanKind,
attributes: Vec<Attribute>,
parent: Arc<dyn Span>,
) -> Arc<dyn Span>;
fn namespace(&self) -> Option<&'static str>;
}Expand description
The Tracer trait is responsible for creating spans and managing the active span in distributed tracing.
This trait defines methods for starting new spans, starting spans with a parent, and retrieving the namespace of the tracer.
Required Methods§
Sourcefn start_span(
&self,
name: Cow<'static, str>,
kind: SpanKind,
attributes: Vec<Attribute>,
) -> Arc<dyn Span>
fn start_span( &self, name: Cow<'static, str>, kind: SpanKind, attributes: Vec<Attribute>, ) -> Arc<dyn Span>
Starts a new span with the given name and type.
The newly created span will have the “current” span as a parent.
§Arguments
name: The name of the span to start.kind: The type of the span to start.attributes: A vector of attributes to associate with the span.
§Returns
An Arc<dyn Span> representing the started span.
Sourcefn start_span_with_parent(
&self,
name: Cow<'static, str>,
kind: SpanKind,
attributes: Vec<Attribute>,
parent: Arc<dyn Span>,
) -> Arc<dyn Span>
fn start_span_with_parent( &self, name: Cow<'static, str>, kind: SpanKind, attributes: Vec<Attribute>, parent: Arc<dyn Span>, ) -> Arc<dyn Span>
Starts a new child with the given name, type, and parent span.
§Arguments
name: The name of the span to start.kind: The type of the span to start.attributes: A vector of attributes to associate with the span.parent: The parent span to use for the new span.
§Returns
An Arc<dyn Span> representing the started span
Note: This method may panic if the parent span cannot be downcasted to the expected type.