Getting payload size in a `tower::Layer`
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
I am trying to create a [`Layer`](https://docs.rs/tower/latest/tower/trait.Layer.html) that tracks metrics for my gRPC service.
I'd like to follow the [OTEL semantic conventions for RPC](https://opentelemetry.io/docs/specs/semconv/rpc/rpc-metrics).
I having trouble implementing [`rpc.server.request.size`](https://opentelemetry.io/docs/specs/semconv/rpc/rpc-metrics/#metric-rpcserverrequestsize) as I can't seem to find a way to get the size of the message we send over the wire.
I came across [`fn size_hint()`](https://docs.rs/tonic/latest/tonic/transport/trait.Body.html#method.size_hint) on body but from what I can tell its only implemented for streams? (from my testing its always `SizeHint { lower: 0, upper: None }`)
Is there any way to get the payload size from a `Layer` middleware?
Contributor guide
Assessment
This issue has not been assessed yet.