Comments (9)
(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.
@hawkw the second syntax seems better as a user, thanks for the pointer to MetaList
.
from tracing.
@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.
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.
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.
from tracing.
Makes sense to me!
from tracing.
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.
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)
- `#[tracing::instrument(err)]` fails to build when Ok variant has lifetime, "lifetime may not live long enough"
- osv-scanner results HOT 4
- Different timestamps in different outputs HOT 5
- Expose simultaneous access to Span and Inner on Instrumented so that implementation of foreign traits are possible HOT 2
- tracings-subscriber: add display_span_list and display_current_span from Json formatter to Pretty, Compact and Full HOT 1
- `EnvFilter` enable span and events for a given field value pair `[{field=\"value\"}]` with no specific span or target
- Change `Layer` timer implementation at runtime using reload HOT 1
- Instrument an empty field in a function with multiple layers in subscriber, the log output will contain the empty field multiple times. HOT 2
- Make `in_current_span` work on Fn types HOT 1
- When the `tracing-subscriber` exits the block, it loses the file handle. HOT 3
- Enrich events with a template string without interpolation
- Cannot activate `tracing-subscriber/tracing-log` feature for pretty log formatting when manually registering global logger HOT 1
- It's not possible to check the source of a `tracing_subscriber::util::TryInitError` HOT 1
- Confusion when reading doc examples for MakeWriterExt in tracing-subscriber HOT 4
- `tracing::instrument` triggers `clippy::used_underscore_bindings` on unused arguments starting with underscore
- logging full containers (structures) HOT 2
- Weird behavior of `tracing::instrument` macro when `tracing/log` feature is enabled
- Adding #[instrument] to a one-line function produces an unused_braces warning HOT 2
- tracing-journald in source does not match published crate HOT 1
- `info!`/`error!`/`warn!` macros don't accept constants for first field name HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tracing.