-
Notifications
You must be signed in to change notification settings - Fork 676
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
Alternative field wrappers in tracing-attributes
#1089
Comments
Thanks for the suggestion, this is an interesting idea! Note, though, that you can also do this by skipping all the automatically-generated fields, and adding custom fields using your own wrapper type. For example: #[tracing::instrument(
skip(foo, bar),
fields(foo = ?my_wrapper(foo), bar = ?my_wrapper(bar))
)]
fn my_function(foo: Foo, bar: Bar) {
/// ...
} or similar. You could also have your own custom instrument attribute that wraps Also, in the upcoming |
@hawkw Wrapping may be an option, but I think it would still require a slight refactoring to expose the implementation in a Thanks for considering my use case! |
Hmm, can you explain why? I think wrapper proc macro could just expand to include a I'm definitely not opposed to the option of exposing the Since this could take a little time to design the ideal API for the proc macro internals to expose, I'd like to make sure you have a workaround or stopgap solution that works for your use case in the interim! |
@hawkw Yes, I have a workaround. Since the crate specifies With that said, that feels like something that probably should be changed since it could equally cause unexpected issues for users, but I'm good for now! Thanks! |
Feature Request
Crates
tracing-attributes
Motivation
I am working on a security sensitive application where I do not want to leak information in logs or traces. Since many types implement
Debug
, it is very difficult to manage the security of this trait. However, it is intricately tied to theinstrument
proc-macro.Ideally, I would be able to wrap the macro with customization to use a field wrapper other than
tracing::field::debug
without forkingtracing-attributes
.Proposal
The primary implementation of
instrument
be moved into astruct
with the name of the wrapperfn
as a key.Then, from my own code, I can implement a wrapper that relies on my log safe trait.
Alternatives
tracing-attributes
instrument
macroThe text was updated successfully, but these errors were encountered: