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 #采样器
61,129 每月下载量
用于 38 个 crate (11 直接)
54KB
1K SLoC
rustracing
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