-
Notifications
You must be signed in to change notification settings - Fork 741
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
Add ignored parameters with #[trace_ignore]
#11
Comments
@kleimkuhler that seems reasonable. Alternatively, we could place the attribute on the argument to ignore, as in: #[trace]
fn example(foo: t1, #[trace_ignore] bar: t2, #[trace_ignore] baz: t3) -> t4 {
...
} though I'm not sure if there's existing precedent for attributes on args? |
Yet another option would be passing the ignored fields as an argument to the #[trace(ignore = bar, baz)] though that seems potentially confusing. We could also just make the #[trace(foo)]
fn example(foo: t1, bar: t2, baz: t3) -> t4 {
...
} to ignore I'm not sure which is the most ergonomic syntax --- @davidbarsky, any opinions? |
Of those options I think Opt-in vs opt-out is something I'd be interested to hear @davidbarsky thoughts on! I'm not really sure if one makes sense over the other. |
Yeah, I'm inclined to agree that putting the attribute on individual
parameters is probably not the most intuitive, since AFAIK there's not
really much precedent for attributes on function args.
Beyond that I'm fine with whatever, as long as `#[trace]` on its own
defaults to recording all the parameters (which IMO is going to be the most
common case).
|
(assuming Using the macro a little bit I've found that I want nearly all of the arguments in functions where it's used. Based on this, I'd have a preference for an opt-out argument to the macro. I'd also have a preference for the shortest argument name possible, something like |
Makes sense to me! |
I'd be happy to work on a PR for this, using Would multiple
|
@hdevalence I'm fine with that proposal. As an alternative, we could also do something like: #[instrument(skip(a, b))]
fn instrumented_fn(a: A, b: B, c: C) { /* ... */ } possibly using something like |
@hawkw the second syntax seems better as a user, thanks for the pointer to |
## Motivation This adds a `skip` directive to the `#[instrument]` macro that allows specifying one or more arguments to the function which will not appear in the generated span. In particular, this means that it's possible to use `#[instrument]` on functions with a non-`Debug` parameter. ## Solution The interior of a `skip(arg1, arg2)` argument is scanned for identifiers and these are filtered out of the identifier list used to generate the span. Closes #11.
As mentioned in #5:
I think this could be easier to add now that parameters are passed into
span!
. @hawkw was what you had in mind for this something like this?The text was updated successfully, but these errors were encountered: