Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

instrument macro: add skip-all-except option #754

Open
rusty-objects opened this issue Jun 16, 2020 · 2 comments
Open

instrument macro: add skip-all-except option #754

rusty-objects opened this issue Jun 16, 2020 · 2 comments

Comments

@rusty-objects
Copy link

Feature Request

Add an ability to skip all arguments in the instrument macro.

Motivation

Currently, instrument requires explicit opt-out to avoid capturing arguments in a span. For some use cases, like those where arguments might contain sensitive data (e.g. passwords) that authors don't want to leak into logs, an opt-out model presents a risk where authors need to be diligent to include every sensitive argument in the opt-out list. A more manageable option would be to suppress all arguments and allow explicit opt-in for insensitive arguments.

Proposal

Add another option such as skip-all-except (or a more suitable name), which can take as its nested fields the arguments that the span should capture. When both skip and skip-all-except are present, the compiler could error.

Alternatives

An alternative would be to add a feature flag that sets the default behavior of the instrument macro to be to suppress all, but then there'd still need to be an option to opt into arguments to unsuppress.

@hawkw
Copy link
Member

hawkw commented Jun 30, 2020

The plan is that in tracing-attributes v0.2, fields in instrument will be opt-in rather than opt-out. Since #672 added support for arbitrary expressions as fields to instrument, you will be able to specify what fields you want to include using the same syntax as the span! and event! macros (including local variable shorthand). This should make skipping fields unnecessary.

@hawkw hawkw added this to the tracing-attributes 0.2 milestone Jul 7, 2020
@PoignardAzur
Copy link

Is there any roadmap for when tracing-attributes 0.2 will come out?

I'm starting to add #[instrument] to my crate and having to skip fields manually is a big pain point.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants