[][src]Struct opentracingrust::tracers::FileTracer

pub struct FileTracer { /* fields omitted */ }

A tracer that writes spans to an std::io::Write.

Useful for local testing, experiments, tests. NOT suited for production use!

Intended to write spans to stderr but can also be used to write spans to stdout or files.

Examples

extern crate opentracingrust;

use std::io;
use std::time::Duration;

use opentracingrust::FinishedSpan;
use opentracingrust::tracers::FileTracer;
use opentracingrust::utils::GlobalTracer;
use opentracingrust::utils::ReporterThread;


fn main() {
    let (tracer, receiver) = FileTracer::new();
    GlobalTracer::init(tracer);

    let reporter = ReporterThread::new_with_duration(
        receiver, Duration::from_millis(50), |span| {
            let mut stderr = io::stderr();
            FileTracer::write_trace(span, &mut stderr).unwrap();
        }
    );

    // ... snip ...
}

Methods

impl FileTracer[src]

pub fn new() -> (Tracer, SpanReceiver)[src]

Instantiate a new file tracer.

pub fn write_trace<W: Write>(span: FinishedSpan, file: &mut W) -> Result<()>[src]

Function to write a FinishedSpan to a stream.

Used to send FinishedSpans to an std::io::Write stream.

Trait Implementations

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.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,