-
Notifications
You must be signed in to change notification settings - Fork 661
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]: add ret(err, ok)
#2970
base: master
Are you sure you want to change the base?
Conversation
#[instrument(ret)] emits an event for any return value, it has no visibility into the return type. #[instrument(err)] emits only Err values, there is no way to emit only Ok values.
d29f90a
to
7f47ae7
Compare
7f47ae7
to
77bb24e
Compare
Please let me know if there's anything I can do to ease review on this. Also, is |
I'll review now. Please keep this pointed at master; we'll handle backports. |
As proposed in #2963 (comment).
Motivation
Ok
return values#[instrument(ret, err)]
interface feels a little weird becauseret
either means "any return value" or "theOk
return value" depending on whethererr
is also presentSolution
This solution is fully backwards-compatible (i.e. the
#[instrument(ret, err)]
syntax continues to work), but adds a more consistent interface using#[instrument(ret(ok(...), err(...)))]
. As such, it could also be backported to the v0.1.x branch.Trying to use both syntaxes at the same time results in a compile error rather than weird behaviour.
I also cleaned up and fixed the documentation and tests while I was at it (best reviewed commit by commit).