hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
9.8k stars 998 forks source link

feat: add debug spans for decoding requests #1760

Open neoeinstein opened 3 months ago

neoeinstein commented 3 months ago

Closes: #1759

Motivation

Adds optional debug spans into the decoder state. At the same time, it resolves a size regression in the State struct, which got much larger because of the inclusion of the Status in the error. The size change overall is from 16 bytes (v0.11.0) to 176 (master) to 56 (this PR).

Solution

Adds tracing spans at the debug level for tracking decoding of streaming messages. This should have negligible overhead when debug spans are not enabled, and provide some more context when they are enabled.

Boxes the Status in the Error variant to avoid size bloat for the common case.

If desired, this functionality could be gated behind a feature, but I start off by avoiding the extra complexity of adding conditional compilation code.

neoeinstein commented 3 months ago

I wonder if there's value in more explicit boxing of Status, or if Status should internally box in order to reduce its size.

djc commented 3 months ago

This seems reasonable to me, thanks! (Sorry for the delay in reviewing.)

I wonder if there's value in more explicit boxing of Status, or if Status should internally box in order to reduce its size.

Could make sense to evaluate this next, in a separate PR? How/why is the size of Status causing issues for you?