3 stable releases

1.1.0 Dec 9, 2024
1.0.1 Aug 22, 2024
1.0.0 Apr 30, 2024

#314 in Web programming

Download history 3993/week @ 2024-10-27 4449/week @ 2024-11-03 6644/week @ 2024-11-10 8756/week @ 2024-11-17 8125/week @ 2024-11-24 7975/week @ 2024-12-01 8190/week @ 2024-12-08 8346/week @ 2024-12-15 3926/week @ 2024-12-22 5870/week @ 2024-12-29 11541/week @ 2025-01-05 10850/week @ 2025-01-12 12230/week @ 2025-01-19 13862/week @ 2025-01-26 15019/week @ 2025-02-02 15256/week @ 2025-02-09

56,874 downloads per month
Used in 3 crates

MIT license

54KB
1K SLoC

cf-rustracing

Crates.io: cf-rustracing Documentation License: MIT

OpenTracing API for Rust.

Documentation

Examples

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

#[tokio::main]
async fn main() {
    // Creates a tracer
    let (tracer, mut span_rx) = Tracer::new(AllSampler);
    {
        // 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`
    
    println!("# SPAN: {:?}", span_rx.recv().await);
    println!("# SPAN: {:?}", span_rx.recv().await);
}

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

~3.5–9.5MB
~91K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy