cf-rustracing-jaeger

Crates.iocf-rustracing-jaeger
lib.rscf-rustracing-jaeger
version1.2.0
sourcesrc
created_at2024-04-30 19:45:36.586067
updated_at2024-07-16 12:32:00.380388
descriptionJaeger client library created on top of rustracing
homepagehttps://github.com/cloudflare/rustracing_jaeger
repositoryhttps://github.com/cloudflare/rustracing_jaeger
max_upload_size
id1225473
size144,157
rust-crate-owners (github:cloudflare:rust-crate-owners)

documentation

README

cf-rustracing-jaeger

Crates.io: rustracing_jaeger Documentation License: MIT

Jaeger client library created on top of cf-rustracing.

Documentation

Examples

Basic Usage

use cf_rustracing::sampler::AllSampler;
use cf_rustracing_jaeger::Tracer;
use cf_rustracing_jaeger::reporter::JaegerCompactReporter;
use std::net::Ipv4Addr;

#[tokio::main]
async fn main() {
    // Creates a tracer
    let (tracer, mut span_rx) = Tracer::new(AllSampler);
    {
        let span = tracer.span("sample_op").start();
        // Do something
    
    } // The dropped span will be sent to `span_rx`
    
    let span = span_rx.recv().await.unwrap();
    assert_eq!(span.operation_name(), "sample_op");
    
    // Reports this span to the local jaeger agent
    let reporter = JaegerCompactReporter::new(
        "sample_service",
        (Ipv4Addr::LOCALHOST, 6831).into(),
        (Ipv4Addr::LOCALHOST, 0).into(),
    )
    .await
    .unwrap();
    
    reporter.report(&[span]).await.unwrap();
}

Executes report.rs example

# Run jaeger in background
$ docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest

# Report example spans
$ cargo run --example report

# View spans (see the image below)
$ firefox http://localhost:16686/

Jaeger UI

References

Commit count: 138

cargo fmt