Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Xiretza
Copy link

@Xiretza Xiretza commented May 15, 2024

As proposed in #2963 (comment).

Motivation

  1. There is currently no way to emit only Ok return values
  2. The #[instrument(ret, err)] interface feels a little weird because ret either means "any return value" or "the Ok return value" depending on whether err is also present

Solution

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).

@Xiretza Xiretza requested review from hawkw, davidbarsky and a team as code owners May 15, 2024 20:52
#[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.
@Xiretza
Copy link
Author

Xiretza commented May 23, 2024

Please let me know if there's anything I can do to ease review on this. Also, is master the correct branch to target, or should I use v0.1.x if I actually want to see it in a release after it's merged?

@davidbarsky
Copy link
Member

Please let me know if there's anything I can do to ease review on this. Also, is master the correct branch to target, or should I use v0.1.x if I actually want to see it in a release after it's merged?

I'll review now. Please keep this pointed at master; we'll handle backports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants