mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
trace: fix level_span macros not propagating parents (#1167)
Currently, when the `trace_span!`, `debug_span!`, `info_span!`, `warn_span!`, and `error_span!` macros are invoked with an explicit parent, a name, and zero or more fields (no target), the macros don't pass along the explicitly provided parent when expanding to the `span!` macro. This is likely due to an oversight on my part. This branch fixes these macros by adding the parent into the `span!` macro expansion. I've also added a test to catch regressions Shoutout to @jonhoo for catching this one! Signed-off-by: Eliza Weisman <[email protected]>
This commit is contained in:
@@ -220,7 +220,13 @@ where
|
||||
Some(Parent::Explicit(expected_parent)) => {
|
||||
let actual_parent =
|
||||
span.parent().and_then(|id| spans.get(id)).map(|s| s.name);
|
||||
assert_eq!(Some(expected_parent.as_ref()), actual_parent);
|
||||
assert_eq!(
|
||||
Some(expected_parent.as_ref()),
|
||||
actual_parent,
|
||||
"expected {:?} to have explicit parent {:?}",
|
||||
name,
|
||||
expected_parent,
|
||||
);
|
||||
}
|
||||
Some(Parent::ContextualRoot) => {
|
||||
assert!(
|
||||
@@ -243,7 +249,13 @@ where
|
||||
let stack = self.current.lock().unwrap();
|
||||
let actual_parent =
|
||||
stack.last().and_then(|id| spans.get(id)).map(|s| s.name);
|
||||
assert_eq!(Some(expected_parent.as_ref()), actual_parent);
|
||||
assert_eq!(
|
||||
Some(expected_parent.as_ref()),
|
||||
actual_parent,
|
||||
"expected {:?} to have contextual parent {:?}",
|
||||
name,
|
||||
expected_parent,
|
||||
);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user