14 releases (7 breaking)

0.21.1 Sep 23, 2024
0.20.0 Aug 31, 2024
0.19.0 Jun 30, 2024
0.18.1 Mar 9, 2024
0.12.0 Jul 2, 2023

#633 in Debugging

Download history 897/week @ 2024-07-15 1051/week @ 2024-07-22 1615/week @ 2024-07-29 2162/week @ 2024-08-05 1668/week @ 2024-08-12 1833/week @ 2024-08-19 1802/week @ 2024-08-26 1288/week @ 2024-09-02 1457/week @ 2024-09-09 1752/week @ 2024-09-16 2395/week @ 2024-09-23 1738/week @ 2024-09-30 1478/week @ 2024-10-07 2472/week @ 2024-10-14 2594/week @ 2024-10-21 2699/week @ 2024-10-28

9,317 downloads per month

CC0 license

47KB
662 lines

tonic-tracing-opentelemetry

crates license crate version

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Middlewares and tools to integrate tonic + tracing + opentelemetry for client and server.

Really early, missing lot of features, help is welcomed.

  • Read OpenTelemetry header from the incoming requests
  • Start a new trace if no trace is found in the incoming request
  • Trace is attached into tracing's span

For examples, you can look at the examples folder.

Extract of client.rs:

    let channel = Channel::from_static("http://127.0.0.1:50051")
        .connect()
        .await?; //Devskim: ignore DS137138
    let channel = ServiceBuilder::new()
        .layer(OtelGrpcLayer::default())
        .service(channel);

    let mut client = GreeterClient::new(channel);

    //...

    opentelemetry::global::shutdown_tracer_provider();

Extract of server.rs:

    Server::builder()
        // create trace for every request including health_service
        .layer(server::OtelGrpcLayer::default().filter(filters::reject_healthcheck))
        .add_service(health_service)
        .add_service(reflection_service)
        //.add_service(GreeterServer::new(greeter))
        .add_service(GreeterServer::new(greeter))
        .serve_with_shutdown(addr, shutdown_signal())
        .await?;

TODO

Changelog - History

CHANGELOG.md

Dependencies

~9–16MB
~198K SLoC