-
Notifications
You must be signed in to change notification settings - Fork 742
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
#[instrument(ret)] behaviour does not match documentation, also reports errors #2963
Comments
I may be wrong, but I think that without (compile time) reflection, the documented behavior is impossible? Or rather, the macro can look if the resulting type is named In a similar fashion someone could name their type So I think we should just change the docs to remove the note and possibly clarify elsewhere? |
You're probably right, how about adding something like |
We should probably change the documentation to reflect that this behavior is specific to the |
Personally I would still find it useful to have an attribute that logs only successful returns. I don't really care about errors, they bubble up to the top and get logged eventually anyway, but I do care about the calculation result in the good case. |
All that would be needed for this is to support turning off Alternatively, we could split |
If we're talking about doing breaking changes, how about this concept:
Where
If this sounds workable, I can get started on an implementation. |
Bug Report
Version
Platform
Arch Linux, kernel 6.8.5-arch1-1
Crates
tracing-attributes
Description
The documentation claims that:
This is however only the case when the
#[instrument]
macro is also given theerr
parameter; otherwise, the return value is printed unconditionally (whether it isOk
orErr
). This can also be seen in the implementation, which has amatch
block whenerr
is specified, but does not have a match block when onlyret
is specified.I've been trying to do some code archaeology to find out why it was implemented and documented this way in #1716, but I've come up empty.
Reproducer:
The text was updated successfully, but these errors were encountered: