tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.4k stars 709 forks source link

Exit spans the same way we enter them #2872

Open jonhoo opened 8 months ago

jonhoo commented 8 months ago

We call inner.enter before we call layer.on_enter, so it feels wrong to then call inner.exit before we call layer.on_exit. Either the inner's view of the span wraps the outer's view of the span, or the other way around.

Motivation

The current behavior feels wrong. I haven't actually run into anything breaking because of this, but while reading through it code having the same ordering in enter and exit (as opposed to inverted ordering on exit) just seemed odd.

jonhoo commented 8 months ago

Worth noting that this could probably also be changed on 0.1.x, but I figured I'd try master first since it's presumably breaking in other ways too, so it'd matter less here if it did change behavior.