[][src]Trait opentelemetry::api::trace::tracer::Tracer

pub trait Tracer: Debug + 'static {
    type Span: Span;
    fn invalid(&self) -> Self::Span;
fn start(&self, name: &str, parent_span: Option<SpanContext>) -> Self::Span;
fn span_builder(&self, name: &str) -> SpanBuilder;
fn build(&self, builder: SpanBuilder) -> Self::Span;
fn get_active_span(&self) -> Self::Span;
fn mark_span_as_active(&self, span: &Self::Span);
fn mark_span_as_inactive(&self, span_id: SpanId);
fn clone_span(&self, span: &Self::Span) -> Self::Span; }

Interface for constructing Spans.

Associated Types

type Span: Span

The Span type used by this Tracer.

Loading content...

Required methods

fn invalid(&self) -> Self::Span

Returns a span with an invalid SpanContext. Used by functions that need to return a default span like get_active_span if no span is present.

fn start(&self, name: &str, parent_span: Option<SpanContext>) -> Self::Span

Starts a new Span.

By default the currently active Span is set as the new Span's parent. The Tracer MAY provide other default options for newly created Spans.

Span creation MUST NOT set the newly created Span as the currently active Span by default, but this functionality MAY be offered additionally as a separate operation.

Each span has zero or one parent spans and zero or more child spans, which represent causally related operations. A tree of related spans comprises a trace. A span is said to be a root span if it does not have a parent. Each trace includes a single root span, which is the shared ancestor of all other spans in the trace. Implementations MUST provide an option to create a Span as a root span, and MUST generate a new TraceId for each root span created. For a Span with a parent, the TraceId MUST be the same as the parent. Also, the child span MUST inherit all TraceState values of its parent by default.

A Span is said to have a remote parent if it is the child of a Span created in another process. Each propagators' deserialization must set is_remote to true on a parent SpanContext so Span creation knows if the parent is remote.

fn span_builder(&self, name: &str) -> SpanBuilder

Creates a span builder

An ergonomic way for attributes to be configured before the Span is started.

fn build(&self, builder: SpanBuilder) -> Self::Span

Create a span from a SpanBuilder

fn get_active_span(&self) -> Self::Span

Returns the current active span.

When getting the current Span, the Tracer MUST return a placeholder Span with an invalid SpanContext if there is no currently active Span.

fn mark_span_as_active(&self, span: &Self::Span)

Mark a given Span as active.

The Tracer MUST provide a way to update its active Span, and MAY provide convenience methods to manage a Span's lifetime and the scope in which a Span is active. When an active Span is made inactive, the previously-active Span SHOULD be made active. A Span maybe finished (i.e. have a non-null end time) but still be active. A Span may be active on one thread after it has been made inactive on another.

NOTE: The mark_span_as_active/mark_span_as_inactive functions MUST be used together or you can end up retaining references to the currently active Span. If you do not want to manage active state of Spans manually, use the with_span API defined for all Tracers via TracerGenerics

fn mark_span_as_inactive(&self, span_id: SpanId)

Remove span from active span

When an active Span is made inactive, the previously-active Span SHOULD be made active. A Span maybe finished (i.e. have a non-null end time) but still be active. A Span may be active on one thread after it has been made inactive on another.

NOTE: The mark_span_as_active/mark_span_as_inactive functions MUST be used together or you can end up retaining references to the currently active Span. If you do not want to manage active state of Spans manually, use the with_span API defined for all Tracers via TracerGenerics

fn clone_span(&self, span: &Self::Span) -> Self::Span

Clone a span created by this tracer.

Loading content...

Implementors

impl Tracer for NoopTracer[src]

type Span = NoopSpan

fn invalid(&self) -> Self::Span[src]

Returns a NoopSpan as they are always invalid.

fn start(&self, _name: &str, _context: Option<SpanContext>) -> Self::Span[src]

Starts a new NoopSpan.

fn span_builder(&self, name: &str) -> SpanBuilder[src]

Starts a SpanBuilder

fn build(&self, _builder: SpanBuilder) -> Self::Span[src]

Builds a NoopSpan from a SpanBuilder

fn get_active_span(&self) -> Self::Span[src]

Returns a new NoopSpan as this tracer does not maintain a registry.

fn mark_span_as_active(&self, _span: &Self::Span)[src]

Ignores active span state.

fn mark_span_as_inactive(&self, _span_id: SpanId)[src]

Ignores active span state.

impl Tracer for BoxedTracer[src]

type Span = BoxedSpan

Global tracer uses BoxedSpans so that it can be a global singleton, which is not possible if it takes generic type parameters.

fn invalid(&self) -> Self::Span[src]

Returns a span with an inactive SpanContext. Used by functions that need to return a default span like get_active_span if no span is present.

fn start(&self, name: &str, parent_span: Option<SpanContext>) -> Self::Span[src]

Starts a new Span.

Each span has zero or one parent spans and zero or more child spans, which represent causally related operations. A tree of related spans comprises a trace. A span is said to be a root span if it does not have a parent. Each trace includes a single root span, which is the shared ancestor of all other spans in the trace.

fn span_builder(&self, name: &str) -> SpanBuilder[src]

Creates a span builder

An ergonomic way for attributes to be configured before the Span is started.

fn build(&self, builder: SpanBuilder) -> Self::Span[src]

Create a span from a SpanBuilder

fn get_active_span(&self) -> Self::Span[src]

Returns the current active span.

When getting the current Span, the Tracer will return a placeholder Span with an invalid SpanContext if there is no currently active Span.

fn mark_span_as_active(&self, span: &Self::Span)[src]

Mark a given Span as active.

fn mark_span_as_inactive(&self, span_id: SpanId)[src]

Mark a given Span as inactive.

fn clone_span(&self, span: &Self::Span) -> Self::Span[src]

Clone span

impl Tracer for Tracer[src]

type Span = Span

This implementation of api::Tracer produces sdk::Span instances.

fn invalid(&self) -> Self::Span[src]

Returns a span with an inactive SpanContext. Used by functions that need to return a default span like get_active_span if no span is present.

fn start(&self, name: &str, parent_span: Option<SpanContext>) -> Self::Span[src]

Starts a new Span.

Each span has zero or one parent spans and zero or more child spans, which represent causally related operations. A tree of related spans comprises a trace. A span is said to be a root span if it does not have a parent. Each trace includes a single root span, which is the shared ancestor of all other spans in the trace.

fn span_builder(&self, name: &str) -> SpanBuilder[src]

Creates a span builder

An ergonomic way for attributes to be configured before the Span is started.

fn build(&self, builder: SpanBuilder) -> Self::Span[src]

Starts a span from a SpanBuilder.

Each span has zero or one parent spans and zero or more child spans, which represent causally related operations. A tree of related spans comprises a trace. A span is said to be a root span if it does not have a parent. Each trace includes a single root span, which is the shared ancestor of all other spans in the trace.

fn get_active_span(&self) -> Self::Span[src]

Returns the current active span.

When getting the current Span, the Tracer will return a placeholder Span with an invalid SpanContext if there is no currently active Span.

fn mark_span_as_active(&self, span: &Self::Span)[src]

Mark a given Span as active.

fn mark_span_as_inactive(&self, span_id: SpanId)[src]

Mark a given Span as inactive.

fn clone_span(&self, span: &Self::Span) -> Self::Span[src]

Clone span

Loading content...