1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
//! [Jaeger][jaeger] client library created on top of [rustracing].
//!
//! [jaeger]: https://github.com/jaegertracing/jaeger
//! [rustracing]: https://crates.io/crates/rustracing
//!
//! # Examples
//!
//! ```
//! use rustracing::sampler::AllSampler;
//! use rustracing_jaeger::Tracer;
//! use rustracing_jaeger::reporter::JaegerCompactReporter;
//!
//! // Creates a tracer
//! let (span_tx, span_rx) = crossbeam_channel::bounded(10);
//! let tracer = Tracer::with_sender(AllSampler, span_tx);
//! {
//! let span = tracer.span("sample_op").start();
//! // Do something
//!
//! } // The dropped span will be sent to `span_rx`
//!
//! let span = span_rx.try_recv().unwrap();
//! assert_eq!(span.operation_name(), "sample_op");
//!
//! // Reports this span to the local jaeger agent
//! let reporter = JaegerCompactReporter::new("sample_service").unwrap();
//! reporter.report(&[span]).unwrap();
//! ```
#![warn(missing_docs)]
#[macro_use]
extern crate trackable;
pub use self::span::Span;
pub use self::tracer::Tracer;
pub use rustracing::{Error, ErrorKind, Result};
pub mod reporter;
pub mod span;
pub mod thrift;
mod constants;
mod error;
mod tracer;
#[cfg(test)]
mod tests {
use crate::reporter::JaegerCompactReporter;
use crate::Tracer;
use rustracing::sampler::AllSampler;
use rustracing::tag::Tag;
#[test]
fn it_works() {
let (span_tx, span_rx) = crossbeam_channel::bounded(10);
let tracer = Tracer::with_sender(AllSampler, span_tx);
{
let _span = tracer.span("it_works").start();
// do something
}
let span = span_rx.try_recv().unwrap();
assert_eq!(span.operation_name(), "it_works");
let mut reporter = JaegerCompactReporter::new("sample_service").unwrap();
reporter.add_service_tag(Tag::new("foo", "bar"));
reporter.report(&[span]).unwrap();
}
}