-
Notifications
You must be signed in to change notification settings - Fork 28
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
#[autometrics]
does not work well with #[async_trait]
#155
Comments
Hello! Thanks for the report! We tracked that there were issues with async_trait, and at least tried to give a better error message in the unreleased next version of the library, but I think we forgot to also oversee that the timing is correct, sorry for that. Next step to solve this (and we'll do it, I'm writing it here to not forget when we come back to this) is to expand the macro fully to check where the timing advices/hooks are added exactly. I suspect that we'll need to do something special when we detect that the returned value is a boxed future, or when most/all of the work is happening in an anonymous async block |
This may also be fixed when timings are fixed, but this issue also causes the |
hi, both issues have been fixed. please note that when instrumenting a whole |
Hmm I'm still not able to make this work, either for the documented attribute ordering or correct error reporting. Here is a minimal repro that uses the
Versions:
|
hi, thanks for your report and the minimal reproduceable example! i have gone ahead and fixed this issue in #164. i tried it out with your example and it seems to work so please update it and let me know if it does. please note that |
Yes I can confirm it works now. Thank you for the quick resolution! |
When using
#[autometrics]
to instrument implementations of traits marked with#[async_trait]
, depending on where you place the macro, either the recorded duration is incorrect or it does not compile.#[async_trait]
is widely used and it would be helpful if it was at least documented that they can't work together.Some examples...
main
1.
#[autometrics]
onfn
This results in the wrong duration reported
2.
#[autometrics]
onimpl
block afterasync_trait
This also results in the incorrect duration
3.
#[autometrics]
onimpl
block beforeasync_trait
This fails to compile with error:
The text was updated successfully, but these errors were encountered: