2 个稳定版本

新版本 1.0.1 2024 年 8 月 22 日
1.0.0 2024 年 4 月 30 日

#338 in 网页编程

Download history 62/week @ 2024-05-03 12/week @ 2024-05-10 13/week @ 2024-05-17 15/week @ 2024-05-24 5/week @ 2024-05-31 46/week @ 2024-06-07 19/week @ 2024-06-14 9/week @ 2024-06-21 124/week @ 2024-07-05 131/week @ 2024-07-12 61/week @ 2024-07-19 109/week @ 2024-07-26 68/week @ 2024-08-02 132/week @ 2024-08-09 279/week @ 2024-08-16

594 每月下载量
cf-rustracing-jaeger 中使用

MIT 许可证

52KB
1K SLoC

cf-rustracing

Crates.io: cf-rustracing Documentation License: MIT

OpenTracing API for Rust.

文档

示例

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);
}

作为一个 crate 的实际使用示例和对 OpenTracing API 的实现,查看 rustracing_jaeger crate 可能有所帮助。

参考

依赖项

~3.5–5MB
~88K SLoC