Skip to content

offer function-level control over tracing#5194

Merged
pchickey merged 4 commits into
bytecodealliance:mainfrom
joeshaw:joeshaw/suppress-tracing
Nov 5, 2022
Merged

offer function-level control over tracing#5194
pchickey merged 4 commits into
bytecodealliance:mainfrom
joeshaw:joeshaw/suppress-tracing

Conversation

@joeshaw
Copy link
Copy Markdown
Contributor

@joeshaw joeshaw commented Nov 3, 2022

This adds to the tracing boolean from the from_witx! macro a disabled_for list of identifiers that allow for suppression of tracing on a per-function basis.

Example:

wiggle::from_witx!({
    tracing: true disable_for {
        module1::func,
        module2::another_func,
    },
    witx: ["..."],
});

Fixes #5193

@pchickey pchickey self-requested a review November 3, 2022 20:58
@github-actions github-actions Bot added the wasi Issues pertaining to WASI label Nov 3, 2022
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 3, 2022

Subscribe to Label Action

cc @kubkon

Details This issue or pull request has been labeled: "wasi"

Thus the following users have been cc'd because of the following labels:

  • kubkon: wasi

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@pchickey
Copy link
Copy Markdown
Contributor

pchickey commented Nov 3, 2022

Thanks. I'd rather not break the current use of tracing: true | false in the macro if we can avoid it. For suppressing it on certain functions, could you add an optional suffix like, perhaps, tracing: true except { module::func, module2::func2 }?

@joeshaw
Copy link
Copy Markdown
Contributor Author

joeshaw commented Nov 3, 2022

Thanks for the feedback, I'll look into it. My worry with except is that you might expect something different if you did tracing: false except { module::func } but there's probably another word we can use.

@pchickey
Copy link
Copy Markdown
Contributor

pchickey commented Nov 3, 2022

It should probably give an error if used in the false case? exclude is another word we could use.

@alexcrichton
Copy link
Copy Markdown
Member

Perhaps:

tracing: true, //  all functions

// ... or ...

tracing: false, // no functions

// ... or ...

tracing: ["..."], // only these functions

Would that work for your use case? I agree we'd ideally avoid various directions of lists here if we could. One possibility would be to support globs as well if families of functions to trace all have similar names. I suppose this could even go so far as to have:

tracing: ["trace-me", "!this-is-not-trace"],

where a ! in front disables tracing for that function (or any other matching globs)

@joeshaw
Copy link
Copy Markdown
Contributor Author

joeshaw commented Nov 4, 2022

@alexcrichton For my use case, I am looking to suppress tracing from a function that carries sensitive information, so negation is the only thing that'd work.

Taking a step back: is there a strong reason to have the tracing config be highly customizable? I think I have a compelling reason for disabling tracing on a particular function but is it important to be able to turn it on for just a few functions?

I'm also hesitant to diverge too much from syntax that already exists. async allows either a catchall (async: *) or a list of identifiers in braces (async: { module::func1, module::func2 }).

@alexcrichton
Copy link
Copy Markdown
Member

Keeping consistent with async seems reasonable, but I think that it's fine to change the syntaxes for both at the same time. I would agree that there's probably not much of a use case for "just this function". Perhaps:

tracing: true,
tracing: false,
tracing_skip: [ ... ]

and that may work?

This will enable more complex tracing rules in the future
It is going to be reused for cases other than just async functions
This adds a `disable_for` syntax after the `tracing` boolean.  For
example:

```
wiggle::from_witx!(
    tracing: true disable_for {
        module1::foo,
        module2::{bar, baz},
    }
)
```
@joeshaw joeshaw force-pushed the joeshaw/suppress-tracing branch from 767e74f to 0957863 Compare November 4, 2022 17:42
@joeshaw
Copy link
Copy Markdown
Contributor Author

joeshaw commented Nov 4, 2022

I pushed a new set of commits that implements what @pchickey suggested (but with disable_for instead of except because I think it flows better even if you change true to false -- but happy to change this back).

Example usage:

wiggle::from_witx!({
    tracing: true disable_for {
        module1::func,
        module2::another_func,
    },
    witx: ["..."],
});

I'm also happy to switch this to be a separate argument altogether (@alexcrichton's tracing_skip suggestion) if that's preferred.

@joeshaw joeshaw marked this pull request as ready for review November 4, 2022 19:03
@alexcrichton
Copy link
Copy Markdown
Member

Seems reasonable to me 👍 but I defer to @pchickey for the final approval

@pchickey pchickey merged commit 1ddf03a into bytecodealliance:main Nov 5, 2022
@pchickey
Copy link
Copy Markdown
Contributor

pchickey commented Nov 5, 2022

Thanks @joeshaw, this is good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi Issues pertaining to WASI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wiggle: Suppress tracing on a per-function basis

3 participants