Open starsoccer opened 1 year ago
Hello,
Your function need to be generic over the RequestBody. Or in your case be specific to http_body::combinators::box_body::BoxBody<bytes::Bytes, Status>>
You can use free function to introduce the generic.
fn on_request<B>(self, request: &Request<B>, _span: &Span) {
tracing::debug!("started")
}
TraceLayer::new_for_grpc()
.make_span_with(DefaultMakeSpan::new().include_headers(true))
.on_request(on_request)
or if you want to use a lambda
TraceLayer::new_for_grpc()
.make_span_with(DefaultMakeSpan::new().include_headers(true))
.on_request(|request: &Request<_>, _span: &Span| {
tracing::debug!("started")
}
)
Thanks the above works, but how would I go about actually logging the request body or response body? For requests the body seems to just be Body(Streaming)
and the response is just UnsyncBoxBody
Following the example here, I am able to create a very bare bones example of logging with grpc, but Id like to be able to define custom methods for on_request, and on_response but cant seem to figure out the correct way to do so.
Ive tried tweaking the ServiceBuilder in the above example to look as follows:
This provides an error saying: