Open audunska opened 1 year ago
Yeah, I think we can just do this https://docs.rs/prost-build/latest/prost_build/struct.Config.html#method.disable_comments but for debug impl? Should be pretty easy to add and isn't a breaking change.
Yeah, I think we can just do this https://docs.rs/prost-build/latest/prost_build/struct.Config.html#method.disable_comments but for debug impl? Should be pretty easy to add and isn't a breaking change.
One would think that, but the Debug impl is generated in prost-derive
as part of the #[derive(Message)]
and friends, and that doesn't have access to the config. I guess we could add a struct attribute to control whether Debug
is generated.
Ah you're right, maybe we can have a attribute option that sets no debug and then that can be enabled via prost-build.
Ah you're right, maybe we can have a attribute option that sets no debug and then that can be enabled via prost-build.
Yes, I am investigating this option.
Related:
We are using tonic, prost and tracing in a service handling customer data. All of our endpoint handler functions look like for example
where the
SearchFilesRequest
is a prost message. This pushes the request body to the tracing provider using itsDebug
implementation. However, we would like to limit the amount of customer data pushed to the tracing provider, while still seeing the structure of the request as well as internal ids.Possible ways of doing this is to manually go through all the endpoints and only push allowed fields to tracing, or to wrap all the request objects in a custom wrapper type with a restricted Debug impl. However, this seems quite brittle and boilerplate-heavy.
One solution that would be really neat is to derive our own Debug impl for the messages, by using a prost_build config with
.type_attribute(".", "#[derive(CustomDebug)]")
. This custom debug deriver could then consult an internal allowlist for which fields to include in the debug output, and which fields to leave out. However, this is not possible ifprost_build
already provides its ownDebug
.So, my question is: Would it be possible to optionally leave out the Debug impl for messages and oneofs?