Skip to main content

grpc_client_layer

Function grpc_client_layer 

Source
pub fn grpc_client_layer() -> GrpcClientTraceLayer
Expand description

Construct the tower Layer that injects the current trace context into outgoing gRPC request metadata.

Requires the tonic-tracing feature. Wrap a tonic tonic::transport::Channel with this before constructing the generated client stub, so calls make from this process propagate traceparent to the callee.

§Example

let channel = tonic::transport::Channel::from_static("http://localhost:50051")
    .connect()
    .await?;
let channel = tower::ServiceBuilder::new()
    .layer(otel_bootstrap::grpc_client_layer())
    .service(channel);