24 releases (12 breaking)

0.29.0 Jun 3, 2025
0.28.0 Mar 31, 2025
0.24.0 Nov 17, 2024
0.19.0 Jun 30, 2024
0.12.0 Jul 2, 2023

#513 in Profiling

Download history 2060/week @ 2025-03-22 2786/week @ 2025-03-29 2326/week @ 2025-04-05 2435/week @ 2025-04-12 2795/week @ 2025-04-19 3664/week @ 2025-04-26 3318/week @ 2025-05-03 5306/week @ 2025-05-10 5234/week @ 2025-05-17 4175/week @ 2025-05-24 5370/week @ 2025-05-31 4118/week @ 2025-06-07 2349/week @ 2025-06-14 4128/week @ 2025-06-21 5359/week @ 2025-06-28 5360/week @ 2025-07-05

17,740 downloads per month

CC0 license

47KB
668 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–18MB
~234K SLoC