Crates.io | tonic-tracing-opentelemetry |
lib.rs | tonic-tracing-opentelemetry |
version | 0.24.0 |
source | src |
created_at | 2023-06-14 21:55:08.232155 |
updated_at | 2024-11-17 12:35:32.360593 |
description | Middlewares and tools to integrate tonic + tracing + opentelemetry. |
homepage | https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk/tree/main/tonic-tracing-opentelemetry |
repository | https://github.com/davidB/tracing-opentelemetry-instrumentation-sdk |
max_upload_size | |
id | 890552 |
size | 16,076 |
Middlewares and tools to integrate tonic + tracing + opentelemetry for client and server.
Really early, missing lot of features, help is welcomed.
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?;