Skip to content

Conversation

@software-artificer
Copy link

Extend the instrument macro to support recording the return and the error values using the valuable::Valuable implementation by writing ret(Valuable) and err(Valuable) respectively.

Motivation

Tracing already comes with valuable support today for various fields. This can be either done through value.as_value() directy or by means of calling tracing::field::valuable(value). However, it does not currently support recording return or error fields when using the #[instrument(err)] or #[instrument(ret)] values. Proposed change introduces this support.

This will further be used by the tracing-opentelemetry to record the exception.type field when the error value implements the Valuable trait and will allow serialization with Valuable for return types.

Solution

The proposal here is pretty simple: add support for err(Valuable) and ret(Valuable), guarded behind the valuable feature flag and also hidden behind the unstable cfg as per current tracing implementation.

Additional context in Tokio Discord.

Extend the `instrument` macro to support recording the return and the
error values using the `valuable::Valuable` implementation by writing
`ret(Valuable)` and `err(Valuable)` respectively.
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.

1 participant