[OpenTracing] API for Rust.
```rust use rustracing::sampler::AllSampler; use rustracing::tag::Tag; use rustracing::Tracer; use std::thread; use std::time::Duration;
// Creates a tracer let (spantx, spanrx) = crossbeamchannel::bounded(10); let tracer = Tracer::withsender(AllSampler, spantx); { // Starts "parent" span let parentspan = tracer.span("parent").startwithstate(()); thread::sleep(Duration::frommillis(10)); { // Starts "child" span let mut childspan = tracer .span("childspan") .childof(&parentspan) .tag(Tag::new("key", "value")) .startwith_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) = spanrx.tryrecv() { 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.