Giter VIP home page Giter VIP logo

Comments (9)

anp avatar anp commented on August 16, 2024 2

(assuming trace -> instrument, please correct me if I'm wrong)

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 skip or not.

from tracing.

hdevalence avatar hdevalence commented on August 16, 2024 1

@hawkw the second syntax seems better as a user, thanks for the pointer to MetaList.

from tracing.

hawkw avatar hawkw commented on August 16, 2024

@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?

from tracing.

hawkw avatar hawkw commented on August 16, 2024

Yet another option would be passing the ignored fields as an argument to the #[trace] attribute, like

#[trace(ignore = bar, baz)]

though that seems potentially confusing.

We could also just make the #[trace] attribute opt-in, so you could say

#[trace(foo)]
fn example(foo: t1, bar: t2, baz: t3) -> t4 {
    ...
}

to ignore bar and baz. Using #[trace] without any arguments would be equivalent to passing all the function's parameters.

I'm not sure which is the most ergonomic syntax --- @davidbarsky, any opinions?

from tracing.

kleimkuhler avatar kleimkuhler commented on August 16, 2024

Of those options I think #[trace(...)] is most reasonable. I don't really like the way tagging individual parameters looks.

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.

from tracing.

hawkw avatar hawkw commented on August 16, 2024

from tracing.

carllerche avatar carllerche commented on August 16, 2024

Makes sense to me!

from tracing.

hdevalence avatar hdevalence commented on August 16, 2024

I'd be happy to work on a PR for this, using skip as suggested above. I'm not sure what the best way to specify multiple arguments-to-skip is.

Would multiple skip parameters work, as in

#[instrument(skip = b, skip = c)]
fn instrumented_fn(a: A, b: B, c: C) { /* ... */ }

from tracing.

hawkw avatar hawkw commented on August 16, 2024

I'd be happy to work on a PR for this, using skip as suggested above. I'm not sure what the best way to specify multiple arguments-to-skip is.

Would multiple skip parameters work, as in

#[instrument(skip = b, skip = c)]
fn instrumented_fn(a: A, b: B, c: C) { /* ... */ }

@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 syn's MetaList. I'm open to either syntax — what do you think feels more natural?

from tracing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.