[][src]Trait opentracingrust::TracerInterface

pub trait TracerInterface: Send + Sync {
    fn extract(&self, fmt: ExtractFormat) -> Result<Option<SpanContext>>;
fn inject(&self, context: &SpanContext, fmt: InjectFormat) -> Result<()>;
fn span(&self, name: &str, options: StartOptions) -> Span; }

Smallest set of operations that a concrete tracer must implement.

While OpenTracingRust users develop against the Tracer structure, the logic of a tracer is implemented through this trait.

Tracer is therefore a wrapper around TracerInterface trait objects and provides some helper methods that are useful for all tracers.

Implementing tracers

OpenTracingRust aims to minimise the amount of work to implement tracers. This is achieved by Boxing traits into structures that are passed around my clients.

The following elements must be provided by tracer implementations:

  • An inner context that implements ImplContext to store a tracer specific span id.
  • An inner tracer that implements TracerInterface to inject/extract/create spans.
  • A function that sends FinishedSpans to the distributed tracer.

How these elements are implemented and what they do is up to the tracer implementation with one exception: FinishedSpans are sent over an crossbeam_channel::unbounded so ImplContext has to be Send.

Examples

If you are looking to implement your tracer checkout the following first:

  • The FileTracer implementation that is part of OpenTracingRust.
  • Example 1-custom-tracer.rs, which implements an in-memory tracer.

Required methods

fn extract(&self, fmt: ExtractFormat) -> Result<Option<SpanContext>>

Attempt to extract a SpanContext from a carrier.

fn inject(&self, context: &SpanContext, fmt: InjectFormat) -> Result<()>

Inject tracing information into a carrier.

fn span(&self, name: &str, options: StartOptions) -> Span

Create a new Span with the given operation name and starting options.

Loading content...

Implementors

impl TracerInterface for FileTracer[src]

fn extract(&self, fmt: ExtractFormat) -> Result<Option<SpanContext>>[src]

Extract a span context from a text map or HTTP headers.

Note that the binary extraction format is not supported by FileTracer.

fn inject(&self, context: &SpanContext, fmt: InjectFormat) -> Result<()>[src]

Inject the span context into a text map or HTTP headers.

Note that the binary injection format is not supported by FileTracer.

impl TracerInterface for NoopTracer[src]

Loading content...