16 unstable releases (3 breaking)

✓ Uses Rust 2018 edition

0.4.0 Feb 3, 2020
0.3.0 Nov 19, 2019
0.2.1 Nov 18, 2019
0.2.0 Mar 18, 2019
0.1.4 Oct 19, 2017

#20 in Web programming

Download history 2306/week @ 2019-12-10 688/week @ 2019-12-17 544/week @ 2019-12-24 435/week @ 2019-12-31 600/week @ 2020-01-07 795/week @ 2020-01-14 615/week @ 2020-01-21 646/week @ 2020-01-28 835/week @ 2020-02-04 967/week @ 2020-02-11 737/week @ 2020-02-18 719/week @ 2020-02-25 593/week @ 2020-03-03 524/week @ 2020-03-10 670/week @ 2020-03-17 667/week @ 2020-03-24

5,665 downloads per month
Used in 19 crates (6 directly)

MIT license

53KB
1K SLoC

rustracing

Crates.io: rustracing Documentation Actions Status Coverage Status License: MIT

OpenTracing API for Rust.

Documentation

Examples

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

// Creates a tracer
let (span_tx, span_rx) = crossbeam_channel::bounded(10);
let tracer = Tracer::with_sender(AllSampler, span_tx);
{
    // Starts "parent" span
    let parent_span = tracer.span("parent").start_with_state(());
    thread::sleep(Duration::from_millis(10));
    {
        // Starts "child" span
        let mut child_span = tracer
            .span("child_span")
            .child_of(&parent_span)
            .tag(Tag::new("key", "value"))
            .start_with_state(());

        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 implementation of the OpenTracing API, it may be helpful to looking at rustracing_jaeger crate.

References

Dependencies

~1.1–1.6MB
~32K SLoC