tracing icon indicating copy to clipboard operation
tracing copied to clipboard

Allow users to specify adding return value to field in instrument attribute

Open xd009642 opened this issue 4 years ago • 2 comments

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

xd009642 avatar Sep 20 '21 16:09 xd009642

Dupe of #1281 I think

BGR360 avatar Nov 29 '21 00:11 BGR360

Is this resolved by https://github.com/tokio-rs/tracing/pull/1716?

CleanCut avatar Jul 27 '22 23:07 CleanCut