mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +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:
@@ -584,6 +584,30 @@ fn explicit_child() {
|
||||
handle.assert_finished();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_child_at_levels() {
|
||||
let (subscriber, handle) = subscriber::mock()
|
||||
.new_span(span::mock().named("foo"))
|
||||
.new_span(span::mock().named("a").with_explicit_parent(Some("foo")))
|
||||
.new_span(span::mock().named("b").with_explicit_parent(Some("foo")))
|
||||
.new_span(span::mock().named("c").with_explicit_parent(Some("foo")))
|
||||
.new_span(span::mock().named("d").with_explicit_parent(Some("foo")))
|
||||
.new_span(span::mock().named("e").with_explicit_parent(Some("foo")))
|
||||
.done()
|
||||
.run_with_handle();
|
||||
|
||||
with_default(subscriber, || {
|
||||
let foo = span!(Level::TRACE, "foo");
|
||||
trace_span!(parent: foo.id(), "a");
|
||||
debug_span!(parent: foo.id(), "b");
|
||||
info_span!(parent: foo.id(), "c");
|
||||
warn_span!(parent: foo.id(), "d");
|
||||
error_span!(parent: foo.id(), "e");
|
||||
});
|
||||
|
||||
handle.assert_finished();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_child_regardless_of_ctx() {
|
||||
let (subscriber, handle) = subscriber::mock()
|
||||
|
||||
Reference in New Issue
Block a user