You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the event formatter implementations provided by tracing-subscriber's fmt module don't actually honor the explicitly-set parent of an event, if one is set. Instead, they will always format a context based on the current span.
See:
No, I tried that for quite a while before I understood that that cannot work: the span is closed, so the .scope() will not include it when iterating, so the span’s fields are not printed by some existing magic :-(
Hmm, after taking a look at format_event, you're right, but that's actually due to a bug in the format_event implementation for the default formatters. It looks like they always print the current span's scope as the context, even if the event has an explicitly set parent. We should fix that, and print the event's explicit parent's scope if one is set. Then, using new_child_of to create the synthesized event would include that span in the scope (since its data is only removed from the registry afteron_close completes).
## Motivation
Currently, the default formatter implementations in
`tracing-subscriber`'s `fmt` module do not handle explicitly set parent
spans for events, such as
```rust
let span = tracing::info_span!("some_interesting_span");
tracing::info!(parent: &span, "something is happening!");
```
Instead, when formatting the span context of an event, the context is
_always_ generated from the current span, even when the event has an
overridden parent. This is not correct.
## Solution
This branch changes the default context formatters to use the explicit
parent ID, if it is present. Otherwise, the contexual parent is used, as
it was previously.
I've also added tests ensuring that this works correctly, and removed
some workarounds for the previous incorrect behavior from the examples.
Fixes#766
Signed-off-by: Eliza Weisman <[email protected]>
Currently, the event formatter implementations provided by tracing-subscriber's
fmt
module don't actually honor the explicitly-set parent of an event, if one is set. Instead, they will always format a context based on the current span.See:
Originally posted by @hawkw in #761
It would be nice to fix this.
The text was updated successfully, but these errors were encountered: