rustracing 0.1.11

OpenTracing API for Rust

rustracing rustracing Documentation Build Status Code Coverage License: MIT

OpenTracing API for Rust.



use rustracing::sampler::AllSampler;
use rustracing::tag::Tag;
use rustracing::Tracer;
use std::thread;
use std::time::Duration;

// Creates a tracer
let (tracer, span_rx) = Tracer::new(AllSampler);
    // Starts "parent" span
    let parent_span = tracer.span("parent").start_with_state(());
        // Starts "child" span
        let mut child_span = tracer
            .tag(Tag::new("key", "value"))

        child_span.log(|log| {
            log.error().message("a log message");
    } // The "child" span dropped and will be sent to `span_rx`
} // The "parent" span dropped and will be sent to `span_rx`

// Outputs finished spans to the standard output
while let Ok(span) = span_rx.try_recv() {
    println!("# SPAN: {:?}", span);

As an actual usage example of the crate and an implmentation of the OpenTracing API, it may be helpful to looking at rustracing_jaeger crate.