-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
Travis is broken, I'll need to add a feature flag on the proc macro feature on stable/beta. |
I removed the feature flag
This is expected, but I wonder how I can tell Travis to only build anything under |
I definitely like this idea 👍 ( haven't reviewed the PR). |
Thanks! There's still some room to improve this.
…On Thu, Oct 4, 2018 at 2:51 PM Carl Lerche ***@***.***> wrote:
I definitely like this idea 👍 ( haven't reviewed the PR).
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB-NPiwSDW7G5qTkdY0Xq28QK7se4j9fks5uhliUgaJpZM4XBMqI>
.
|
I'm guessing that this will have the most win w/ |
Yeah, totally. It's also nice, imo, for cases where someone wants to try
out Tokio Trace in their application's critical path without investing
*too* much
effort, and getting some useful information.
…On Fri, Oct 5, 2018 at 11:27 AM Carl Lerche ***@***.***> wrote:
I'm guessing that this will have the most win w/ async/await.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB-NPvvAQrtrmFAh-2So8gs0tlMsgTM7ks5uh3pIgaJpZM4XBMqI>
.
|
@davidbarsky Since Rust 1.30 was just released, this shouldn't break the build any longer, correct? |
Yes, that's correct. There just might be some breaking changes that have
occurred in Tokio Trace since.
…On Thu, Oct 25, 2018 at 2:22 PM Eliza Weisman ***@***.***> wrote:
@davidbarsky <https://github.com/davidbarsky> Since Rust 1.30 was just
released <https://blog.rust-lang.org/2018/10/25/Rust-1.30.0.html>, this
shouldn't break the build any longer, correct?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB-NPmD_UOrwxW14gAL6COpfGhT2hPssks5uogF8gaJpZM4XBMqI>
.
|
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.
Now that Rust 1.30 is stable, I think we can start thinking about what it takes to merge this branch!
The proc-macro itself is looking good. Most of my requested changes have to do with the project structure etc.
Hmm, actually, I don't think so --- since your macro just farms out to the |
quote_spanned!(call_site=> | ||
#(#attrs) * | ||
#vis #constness #unsafety #asyncness #abi fn #ident(#params) #return_type { | ||
span!(#ident_str, traced_function = #ident_str).enter(move || { |
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.
For future work: it would be really cool if we could pass all the params to the function as fields here as well.
Since some parameters may not be valid span fields, we might consider adding an additional attribute (#[trace_ignore]
?) to annotate those fields that should be skipped.
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.
Agreed, yeah. The biggest blocker on passing all the params to into a span field was the T: Clone
requirement. Now that's gone, it'll be far easier to implement.
|
||
#[proc_macro_attribute] | ||
pub fn trace(_args: TokenStream, item: TokenStream) -> TokenStream { | ||
let input: ItemFn = parse_macro_input!(item as ItemFn); |
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.
Also for potential future work: it would be cool to allow things that aren't functions to be traced. At the very least, it would be nice to detect if we're annotating a future, and instrument it in the "right way" --- by constructing the span once and wrapping the future in a tokio_trace_futures::Instrumented
future.
The naïve approach --- just putting the #[trace]
macro on the implementation of Future::poll
for that future --- wouldn't do the Right Thing; it would instead create a new span that's entered for every individual time that future is polled. This could potentially be a big enough gotcha that I think it's probably worthwhile to special-case this.
We'd probably want to figure out a similar approach for async fn
s as well...
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.
Also for potential future work: it would be cool to allow things that aren't functions to be traced. At the very least, it would be nice to detect if we're annotating a future, and instrument it in the "right way" --- by constructing the span once and wrapping the future in a tokio_trace_futures::Instrumented future.
The naïve approach --- just putting the #[trace] macro on the implementation of Future::poll for that future --- wouldn't do the Right Thing; it would instead create a new span that's entered for every individual time that future is polled. This could potentially be a big enough gotcha that I think it's probably worthwhile to special-case this.
That's a good point, and I'd need to dig deeper into the Syn docs.
We'd probably want to figure out a similar approach for async fns as well...
It already is! See the #asyncness
on line 41? That's all the work we need to do to support async functions, from a macro standpoint.
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.
We'd probably want to figure out a similar approach for async fns as well...
It already is! See the #asyncness on line 41? That's all the work we need to do to support async functions, from a macro standpoint.
Yes, but I think we'd want to make sure we do the right thing for async fn
s --- namely, I think we'd want to make sure that the future created by that async fn is instrumented by that span, rather than just the initial call to the async fn
that returns the future. This may require some testing.
@davidbarsky looks like all the blocking changes I requested were resolved, thanks! Mind opening new issues for the follow-up work (#16 (comment) and #16 (comment))? |
Sure! Gimme about an hour.
…On Mon, Oct 29, 2018 at 4:27 PM Eliza Weisman ***@***.***> wrote:
@davidbarsky <https://github.com/davidbarsky> looks like all the blocking
changes I requested were resolved, thanks!
Mind opening new issues for the follow-up work (#16 (comment)
<#16 (comment)>
and #16 (comment)
<#16 (comment)>
)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB-NPtwdloy69bPOnAATjhRSR192enRHks5up2TCgaJpZM4XBMqI>
.
|
@davidbarsky thanks for creating the followup issues! I believe merging this PR should close #9, since the additional work is now tracked by those tickets. |
Attributes, generics, and other stuff seems to be handled mostly correctly. The main thing that's missing is inserting the function's parameters into a span and checking that a type is clone-able.
The relevant part of the
cargo expand
on the example crate is this: