Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Ensure #[trace] macro works correctly for async functions. #54

Open
davidbarsky opened this issue Oct 29, 2018 · 0 comments
Open

Ensure #[trace] macro works correctly for async functions. #54

davidbarsky opened this issue Oct 29, 2018 · 0 comments
Labels
area/macros Related to macros crate/macros Related to the `tokio-trace-macros` crate kind/enhancement New feature or request

Comments

@davidbarsky
Copy link
Collaborator

Original discussion.

@hawkw

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 fns as well...
[my comment redacted]
Yes, but I think we'd want to make sure we do the right thing for async fns --- 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 davidbarsky added the kind/enhancement New feature or request label Oct 29, 2018
@hawkw hawkw added the crate/macros Related to the `tokio-trace-macros` crate label Nov 5, 2018
@hawkw hawkw added the area/macros Related to macros label Nov 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/macros Related to macros crate/macros Related to the `tokio-trace-macros` crate kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants