tracing icon indicating copy to clipboard operation
tracing copied to clipboard

feature request: #[tracing::instrument(span = &self.span)]

Open jakajancar opened this issue 2 years ago • 0 comments

Feature Request

Allow the span to be set to self.span, not a new span with it as a parent.

Crates

tracing

Motivation

No value in a nested span.

Proposal

Eliza — Today at 1:03 PM personally, i would probably implement that using a new attribute, rather than adding it to #[instrument] --- #[instrument] already does a lot of stuff, and if you added something like this, a lot of the existing instrument arguments wouldn't make sense when the span already exists...

Personally, making span and new-span-related parameters (name, level...) mutually exclusive seems pretty clear to me as well, especially if the two modes ("use existing span" vs create new) are cleanly explained at the top of the docs.

Alternatives

A one-line wrapper function that does original().instrument(self.span).await.

jakajancar avatar Jul 01 '22 19:07 jakajancar