I'm trying to write a (actually two) general ZClientInterceptor that adds metrics and tracing for any outgoing gRPC call for the zio-grpc client.
However, ZClientInterceptor today only allows me to modify the outgoing call, and I have no knowledge about when the call returns.
Ideally, I'd be able to register a wrapper that can follow the entire lifecycle of the call (ideally, in the tracing case, I'd also be able to control the execution in order to do something like Tracing.span(spanName)(outgoingCall) to ease integration with zio-telemetry).
Another use case is to be able to set a deadline on the CallOptions based on the method descriptor. Currently that's not possible because the client call is already created so it's too late.
Hi!
I'm trying to write a (actually two) general
ZClientInterceptor
that adds metrics and tracing for any outgoing gRPC call for the zio-grpc client.However,
ZClientInterceptor
today only allows me to modify the outgoing call, and I have no knowledge about when the call returns.Ideally, I'd be able to register a wrapper that can follow the entire lifecycle of the call (ideally, in the tracing case, I'd also be able to control the execution in order to do something like
Tracing.span(spanName)(outgoingCall)
to ease integration with zio-telemetry).sttp
has some good examples of what such an interface can look like: https://sttp.softwaremill.com/en/latest/backends/wrappers/custom.html (wraps the entire execution) and https://sttp.softwaremill.com/en/latest/backends/wrappers/custom.html#listener-backend (reacts on events and allows one to propagate some state such as start time to measure execution duration).