-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Optionally leave out Debug impl #795
Comments
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 |
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. |
If this comment helps you, please consider updating the crate documentation to make these features more findable. |
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?
The text was updated successfully, but these errors were encountered: