tracing
tracing copied to clipboard
Allow users to specify adding return value to field in instrument attribute
Crates
- tracing-attribute (only one I think)
Feature Request
A thought for the instrument macro, but if one was thinking of a PR to allow people to add a field to it to add the return value to a span field could that accepted i.e.
#[instrument(return_value="result")]
fn foo() -> i32 {
2
}
#[instrument(return_value)]
fn bar() -> i32 {
3
}
// and then span_name{fields} would be:
// foo{result=2}
// bar{returned=3}
As we can see from the example I already kinda have a thought in my head for what the API would look like, it would be an extra field to the attribute called something like "return_value" and if provided a string argument that would be the name of the field otherwise it would pick some sensible default name like "returned".
Dupe of #1281 I think
Is this resolved by https://github.com/tokio-rs/tracing/pull/1716?