-
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
tracing::instrument args by autoref specialization #1612
base: master
Are you sure you want to change the base?
Conversation
3fb7366
to
513e600
Compare
Sorry I haven't reviewed this yet --- I'd like to get the bug fixes for issues in the v0.1.17 release of |
513e600
to
9830f1f
Compare
Rebased over the tracing-attributes split. |
tracing-attributes 0.1.18 has been published. Is there anything specific blocking this, or are we just waiting on person time? |
Sorry, it's on my list of things to do --- I was hoping to spend some time going through the backlog of |
Now that we have #1906, I guess I should look into capturing by- |
1fc27ff
to
232e456
Compare
Alright, this now supports capturing by-
(This can be adjusted if desired; it might make sense to swap |
232e456
to
c56913a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the reminder that this branch exists, i had kind of forgotten about it (sorry!). i'm really excited about this change and i'd love to get it merged --- and once it lands, it would be really nice to use the autoref capture macro in the span!
and event!
macros as well, in a follow-up PR.
i did have a few questions about the change, and it would be nice to have some additional comments explaining some of the details about what's going on here. also, it could be nice to add some more tests for instrument
ensuring that autoref capture behaves correctly --- in particular, it would be nice to have a (cfg-flagged) test that valuable
capture works.
once those comments are addressed, i'll be very excited to merge this!
One thing I just want to confirm is the way we want to handle it: the current order the conversions are tried is
This is the least behavior-changing option, since primitives are currently opportunistically recognized to be captured by- For |
I think this approach makes sense. I think it's reasonable for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, i think this seems ready to merge. thanks again for working on this!
Oh, hmm. I just noticed something kind of unfortunate: releasing a new version of I think there a couple of possible solutions here. One of them is to just release an 0.2 version of Alternatively, we could put the autoref specialization code in @CAD97, what do you think makes the most sense here? Footnotes
|
The optimal solution per my understanding of the proc macro ecosystem is to go back in time and make all tracing dependencies on tracing-attributes an In practice, proc macros are coupled rather tightly to their runtime crate. In a perfect future, the proc macro crate is distributed as part of the runtime package and not a separately versioned artifact. For a comparison point, serde-derive will fail if used with an incompatible version of serde. This isn't an easy situation to get into (modern serde releases have an optional There's also a possibility that the proc-macro->runtime dependency edge won't impact runtime version selection in the future. IIRC So if we want to avoid the case where someone gets broken by upgrading [email protected] without upgrading [email protected], I think the solution would be
Personally I think the proc macro crate version bump isn't really required (unless maybe if there was a period of time where using the crate directly was the recommended usage pattern) because this is (unfortunately) a known limitation of the proc-macro/runtime split. Now for a silly alternative solution: rename the macro |
Yeah...that's fair; I'm also not sure if this is a big deal. I would be pretty surprised if anyone is explicitly depending on My concern was mostly about automated tools like Dependabot bumping just the |
FWIW, if your used version of
both of which seem trivial enough that just doing the version increment seems reasonable enough to me (unless I'm missing something, which is possible) |
FWIW it's worse than that, actually: since Getting a broken version resolution would be as simple as |
Motivation
Option<impl Value>
by value (core: impl field::Value for Option<T> #1585 (review))impl Value
fields byValue
tracing::instrument
, which breaks with e.g. shadowing or qualified pathsMake captured strings filter asbob
not"bob"
, see implement stricter env filter parsing #1542 (comment) for some more contextSolution
Autoref specialization!
#[tracing::instrument]
ed function arguments are now captured via__tracing_capture_value!
, which uses autoref specialization on.__tracing_capture_value()
to first captureValue
types by-Value
, and then captureDebug
types by-Debug
. It could also attempt to capture by-Display
, but I opted to not do so to make a smaller deviation from the current behavior and avoid the potential loss of detail thatDisplay
entails.The
span!
andevent!
macros are unchanged.Demo
master (0fa74b9)
this PR (3fb7366)
Uhh apparently when I did my testing in #1542 I didn't have #1378 🙃
Future
Once capturing by-
Value
means capturing by-Valuable
, this change simultaneously becomes more desirable (more structured argument capture) and more behavior-changing (as more types will potentially capture by-Value
).