19 个版本

0.6.0 2022 年 4 月 5 日
0.5.1 2021 年 1 月 13 日
0.5.0 2020 年 10 月 25 日
0.4.0 2020 年 2 月 3 日
0.1.4 2017 年 10 月 19 日

#3 in #采样器

Download history 10245/week @ 2024-04-23 11159/week @ 2024-04-30 9864/week @ 2024-05-07 10331/week @ 2024-05-14 12188/week @ 2024-05-21 11097/week @ 2024-05-28 10866/week @ 2024-06-04 10870/week @ 2024-06-11 11698/week @ 2024-06-18 13542/week @ 2024-06-25 11046/week @ 2024-07-02 12338/week @ 2024-07-09 13248/week @ 2024-07-16 14283/week @ 2024-07-23 17862/week @ 2024-07-30 13298/week @ 2024-08-06

61,129 每月下载量
用于 38 个 crate (11 直接)

MIT 许可证

54KB
1K SLoC

rustracing

Crates.io: rustracing Documentation Actions Status Coverage Status 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 (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);
}

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

参考

依赖项

~1.8–2.7MB
~58K SLoC