tracing: Entered
guards should be !Send
#698
Labels
crate/tracing
Related to the `tracing` crate
kind/bug
Something isn't working
meta/breaking
This is a breaking change, and should wait until the next breaking release.
Milestone
Bug Report
Version
Crates
tracing
Description
The
Entered
guard returned bySpan::enter
represents entering and exiting a span on the current thread. CallingSpan::enter
enters the span, returning anEntered
, and dropping theEntered
ensures that the span is exited. This ensures that all spans, once entered, are eventually exited.However,
Entered
has an auto-impl ofSend
, because it doesn't contain any!Send
types. This means that theEntered
guard could be sent to another thread and dropped. This would cause the original thread to never exit the span,. and the thread to which theEntered
guard was sent would exit a span that it never observed an enter for. This is incorrect.We should consider making
Entered
!Send
. Technically, this is a breaking change, but the current behavior is incorrect. This would also preventEntered
guards from being held in futures that are bounded withSend
, which would prevent some incorrect uses ofSpan::enter
inasync
blocks...The text was updated successfully, but these errors were encountered: