diff --git a/tokio-trace/examples/counters.rs b/tokio-trace/examples/counters.rs index 3d120405fcd..b8f5c22e814 100644 --- a/tokio-trace/examples/counters.rs +++ b/tokio-trace/examples/counters.rs @@ -125,10 +125,16 @@ fn main() { tokio_trace::subscriber::with_default(subscriber, || { let mut foo: u64 = 2; - span!("my_great_span", foo_count = &foo).enter(|| { + span!(tokio_trace::Level::TRACE, "my_great_span", foo_count = &foo).enter(|| { foo += 1; info!({ yak_shaved = true, yak_count = 1 }, "hi from inside my span"); - span!("my other span", foo_count = &foo, baz_count = 5).enter(|| { + span!( + tokio_trace::Level::TRACE, + "my other span", + foo_count = &foo, + baz_count = 5 + ) + .enter(|| { warn!({ yak_shaved = false, yak_count = -1 }, "failed to shave yak"); }); }); diff --git a/tokio-trace/examples/sloggish/main.rs b/tokio-trace/examples/sloggish/main.rs index 443fb341db9..b20e138b1fb 100644 --- a/tokio-trace/examples/sloggish/main.rs +++ b/tokio-trace/examples/sloggish/main.rs @@ -22,16 +22,37 @@ fn main() { let subscriber = SloggishSubscriber::new(2); tokio_trace::subscriber::with_default(subscriber, || { - span!("", version = &field::display(5.0)).enter(|| { - span!("server", host = "localhost", port = 8080).enter(|| { + span!( + tokio_trace::Level::TRACE, + "", + version = &field::display(5.0) + ) + .enter(|| { + span!( + tokio_trace::Level::TRACE, + "server", + host = "localhost", + port = 8080 + ) + .enter(|| { info!("starting"); info!("listening"); - let mut peer1 = span!("conn", peer_addr = "82.9.9.9", port = 42381); + let mut peer1 = span!( + tokio_trace::Level::TRACE, + "conn", + peer_addr = "82.9.9.9", + port = 42381 + ); peer1.enter(|| { debug!("connected"); debug!({ length = 2 }, "message received"); }); - let mut peer2 = span!("conn", peer_addr = "8.8.8.8", port = 18230); + let mut peer2 = span!( + tokio_trace::Level::TRACE, + "conn", + peer_addr = "8.8.8.8", + port = 18230 + ); peer2.enter(|| { debug!("connected"); }); diff --git a/tokio-trace/src/lib.rs b/tokio-trace/src/lib.rs index da544c57113..f1c10ff81b9 100644 --- a/tokio-trace/src/lib.rs +++ b/tokio-trace/src/lib.rs @@ -58,7 +58,7 @@ //! # #[macro_use] extern crate tokio_trace; //! # fn main() { //! # let n = 1; -//! span!("my loop").enter(|| { +//! span!(tokio_trace::Level::TRACE, "my loop").enter(|| { //! for i in 0..n { //! # let _ = i; //! // ... @@ -73,7 +73,7 @@ //! # let n = 1u64; //! for i in 0..n { //! # let _ = i; -//! span!("my loop", iteration = i).enter(|| { +//! span!(tokio_trace::Level::TRACE, "my loop", iteration = i).enter(|| { //! // ... //! }) //! } @@ -155,8 +155,8 @@ //! # #[macro_use] //! # extern crate tokio_trace; //! # fn main() { -//! // Construct a new span named "my span". -//! let mut span = span!("my span"); +//! // Construct a new span named "my span" with trace log level. +//! let mut span = span!(tokio_trace::Level::TRACE, "my span"); //! span.enter(|| { //! // Any trace events in this closure or code called by it will occur within //! // the span. @@ -196,7 +196,7 @@ //! pub fn shave_the_yak(yak: &mut Yak) { //! // Create a new span for this invocation of `shave_the_yak`, annotated //! // with the yak being shaved as a *field* on the span. -//! span!("shave_the_yak", yak = field::debug(&yak)).enter(|| { +//! span!(tokio_trace::Level::TRACE, "shave_the_yak", yak = field::debug(&yak)).enter(|| { //! // Since the span is annotated with the yak, it is part of the context //! // for everything happening inside the span. Therefore, we don't need //! // to add it to the message for this event, as the `log` crate does. diff --git a/tokio-trace/src/macros.rs b/tokio-trace/src/macros.rs index 4dcd677fb31..668534df3b7 100644 --- a/tokio-trace/src/macros.rs +++ b/tokio-trace/src/macros.rs @@ -7,7 +7,7 @@ /// # #[macro_use] /// # extern crate tokio_trace; /// # fn main() { -/// let mut span = span!("my span"); +/// let mut span = span!(tokio_trace::Level::TRACE, "my span"); /// span.enter(|| { /// // do work inside the span... /// }); @@ -19,7 +19,7 @@ /// # #[macro_use] /// # extern crate tokio_trace; /// # fn main() { -/// span!("my span", foo = 2, bar = "a string").enter(|| { +/// span!(tokio_trace::Level::TRACE, "my span", foo = 2, bar = "a string").enter(|| { /// // do work inside the span... /// }); /// # } @@ -31,6 +31,7 @@ /// # extern crate tokio_trace; /// # fn main() { /// span!( +/// tokio_trace::Level::TRACE, /// "my span", /// foo = 2, /// bar = "a string", @@ -45,7 +46,7 @@ /// # fn main() { /// span!( /// target: "app_span", -/// level: tokio_trace::Level::TRACE, +/// tokio_trace::Level::TRACE, /// "my span", /// foo = 3, /// bar = "another string" @@ -58,7 +59,7 @@ /// # #[macro_use] /// # extern crate tokio_trace; /// # fn main() { -/// let mut my_span = span!("my span", foo = 2, bar); +/// let mut my_span = span!(tokio_trace::Level::TRACE, "my span", foo = 2, bar); /// my_span.record("bar", &7); /// # } /// ``` @@ -79,28 +80,16 @@ /// ``` #[macro_export(local_inner_macros)] macro_rules! span { - ( - target: $target:expr, - level: $lvl:expr, - parent: $parent:expr, - $name:expr, - $($k:ident $( = $val:expr )* ),*, - ) => { + (target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr, $($k:ident $( = $val:expr )* ),*,) => { span!( target: $target, - level: $lvl, parent: $parent, + $lvl, $name, $($k $( = $val)*),* ) }; - ( - target: $target:expr, - level: $lvl:expr, - parent: $parent:expr, - $name:expr, - $($k:ident $( = $val:expr )* ),* - ) => { + (target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr, $($k:ident $( = $val:expr )* ),*) => { { use $crate::callsite; use $crate::callsite::Callsite; @@ -126,12 +115,7 @@ macro_rules! span { } } }; - ( - target: $target:expr, - level: $lvl:expr, - $name:expr, - $($k:ident $( = $val:expr )* ),* - ) => { + (target: $target:expr, $lvl:expr, $name:expr,$($k:ident $( = $val:expr )* ),*) => { { use $crate::callsite; use $crate::callsite::Callsite; @@ -157,34 +141,118 @@ macro_rules! span { } }; - (target: $target:expr, level: $lvl:expr, parent: $parent:expr, $name:expr) => { - span!(target: $target, level: $lvl, parent: $parent, $name,) + (target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr) => { + span!(target: $target, parent: $parent, $lvl, $name,) }; - (level: $lvl:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr )* ),*,) => { + (parent: $parent:expr, $lvl:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { span!( target: __tokio_trace_module_path!(), - level: $lvl, parent: $parent, + $lvl, $name, $($k $( = $val)*),* ) }; - (level: $lvl:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr )* ),*) => { + (parent: $parent:expr, $lvl:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $lvl, parent: $parent, + $lvl, $name, $($k $( = $val)*),* ) }; - (level: $lvl:expr, parent: $parent:expr, $name:expr) => { - span!(target: __tokio_trace_module_path!(), level: $lvl, parent: $parent, $name,) + (parent: $parent:expr, $lvl:expr, $name:expr) => { + span!( + target: __tokio_trace_module_path!(), + parent: $parent, + $lvl, + $name, + ) }; - (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + (target: $target:expr, $lvl:expr, $name:expr, $($k:ident $( = $val:expr )* ),*, + ) => { + span!( + target: $target, + $lvl, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $lvl:expr, $name:expr, $($k:ident $( = $val:expr )* ),*) => { + span!( + target: $target, + $lvl, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $lvl:expr, $name:expr) => { + span!(target: $target, $lvl, $name,) + }; + ($lvl:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { span!( target: __tokio_trace_module_path!(), - level: $crate::Level::TRACE, + $lvl, + $name, + $($k $( = $val)*),* + ) + }; + ($lvl:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: __tokio_trace_module_path!(), + $lvl, + $name, + $($k $( = $val)*),* + ) + }; + ($lvl:expr, $name:expr) => { + span!( + target: __tokio_trace_module_path!(), + $lvl, + $name, + ) + }; +} + +/// Constructs a span at the trace level. +/// +/// # Examples +/// +/// ```rust +/// # #[macro_use] +/// # extern crate tokio_trace; +/// # fn main() { +/// let mut span = trace_span!("my span"); +/// span.enter(|| { +/// // do work inside the span... +/// }); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! trace_span { + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + trace_span!( + target: $target, + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + parent: $parent, + $crate::Level::TRACE, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr) => { + trace_span!(target: $target, parent: $parent, $name,) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + trace_span!( parent: $parent, $name, $($k $( = $val)*),* @@ -193,78 +261,301 @@ macro_rules! span { (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $crate::Level::TRACE, - parent: $parent, + $crate::Level::TRACE, $name, $($k $( = $val)*),* ) }; (parent: $parent:expr, $name:expr) => { + trace_span!(parent: $parent, $name,) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + trace_span!( + target: $target, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + $crate::Level::TRACE, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr) => { + trace_span!(target: $target, $name,) + }; + ($name:expr, $($k:ident $( = $val:expr)*),*,) => { + trace_span!( + $name, + $($k $( = $val)*),* + ) + }; + ($name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $crate::Level::TRACE, + $crate::Level::TRACE, + $name, + $($k $( = $val)*),* + ) + }; + ($name:expr) => {trace_span!($name,)}; +} + +/// Constructs a span at the debug level. +/// +/// # Examples +/// +/// ```rust +/// # #[macro_use] +/// # extern crate tokio_trace; +/// # fn main() { +/// let mut span = debug_span!("my span"); +/// span.enter(|| { +/// // do work inside the span... +/// }); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! debug_span { + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + debug_span!( + target: $target, parent: $parent, $name, + $($k $( = $val)*),* ) }; - ( - target: $target:expr, - level: $lvl:expr, - $name:expr, - $($k:ident $( = $val:expr )* ),*, - ) => { + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: $target, - level: $lvl, + parent: $parent, + $crate::Level::DEBUG, $name, $($k $( = $val)*),* ) }; - ( - target: $target:expr, - level: $lvl:expr, - $name:expr, - $($k:ident $( = $val:expr )* ),* - ) => { + (target: $target:expr, parent: $parent:expr, $name:expr) => { + debug_span!(target: $target, parent: $parent, $name,) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + debug_span!( + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { span!( - target: $target, - level: $lvl, + target: __tokio_trace_module_path!(), + $crate::Level::DEBUG, $name, $($k $( = $val)*),* ) }; - (target: $target:expr, level: $lvl:expr, $name:expr) => { - span!(target: $target, level: $lvl, $name,) + (parent: $parent:expr, $name:expr) => { + debug_span!(parent: $parent, $name,) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + debug_span!( + target: $target, + $name, + $($k $( = $val)*),* + ) }; - (target: $target:expr, level: $lvl:expr, $name:expr,) => { + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: $target, - level: $lvl, + $crate::Level::DEBUG, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr) => { + debug_span!(target: $target, $name,) + }; + ($name:expr, $($k:ident $( = $val:expr)*),*,) => { + debug_span!( $name, + $($k $( = $val)*),* ) }; - (level: $lvl:expr, $name:expr, $($k:ident $( = $val:expr )* ),*,) => { + ($name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $lvl, + $crate::Level::DEBUG, $name, $($k $( = $val)*),* ) }; - (level: $lvl:expr, $name:expr, $($k:ident $( = $val:expr )* ),*) => { + ($name:expr) => {debug_span!($name,)}; +} + +/// Constructs a span at the info level. +/// +/// # Examples +/// +/// ```rust +/// # #[macro_use] +/// # extern crate tokio_trace; +/// # fn main() { +/// let mut span = info_span!("my span"); +/// span.enter(|| { +/// // do work inside the span... +/// }); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! info_span { + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + info_span!( + target: $target, + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + parent: $parent, + $crate::Level::INFO, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr) => { + info_span!(target: $target, parent: $parent, $name,) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + info_span!( + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $lvl, - $name, $($k $( = $val)*),* + $crate::Level::INFO, + $name, + $($k $( = $val)*),* ) }; - (level: $lvl:expr, $name:expr) => { - span!(target: __tokio_trace_module_path!(), level: $lvl, $name,) + (parent: $parent:expr, $name:expr) => { + info_span!(parent: $parent, $name,) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + info_span!( + target: $target, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + $crate::Level::INFO, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr) => { + info_span!(target: $target, $name,) }; ($name:expr, $($k:ident $( = $val:expr)*),*,) => { + info_span!( + $name, + $($k $( = $val)*),* + ) + }; + ($name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $crate::Level::TRACE, + $crate::Level::INFO, + $name, + $($k $( = $val)*),* + ) + }; + ($name:expr) => {info_span!($name,)}; +} + +/// Constructs a span at the warn level. +/// +/// # Examples +/// +/// ```rust +/// # #[macro_use] +/// # extern crate tokio_trace; +/// # fn main() { +/// let mut span = warn_span!("my span"); +/// span.enter(|| { +/// // do work inside the span... +/// }); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! warn_span { + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + warn_span!( + target: $target, + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + parent: $parent, + $crate::Level::WARN, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr) => { + warn_span!(target: $target, parent: $parent, $name,) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + warn_span!( + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: __tokio_trace_module_path!(), + $crate::Level::WARN, + $name, + $($k $( = $val)*),* + ) + }; + (parent: $parent:expr, $name:expr) => { + warn_span!(parent: $parent, $name,) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + warn_span!( + target: $target, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + $crate::Level::WARN, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr) => { + warn_span!(target: $target, $name,) + }; + ($name:expr, $($k:ident $( = $val:expr)*),*,) => { + warn_span!( $name, $($k $( = $val)*),* ) @@ -272,18 +563,100 @@ macro_rules! span { ($name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $crate::Level::TRACE, + $crate::Level::WARN, $name, $($k $( = $val)*),* ) }; - ($name:expr) => { + ($name:expr) => {warn_span!($name,)}; +} +/// Constructs a span at the error level. +/// +/// # Examples +/// +/// ```rust +/// # #[macro_use] +/// # extern crate tokio_trace; +/// # fn main() { +/// let mut span = error_span!("my span"); +/// span.enter(|| { +/// // do work inside the span... +/// }); +/// # } +/// ``` +#[macro_export(local_inner_macros)] +macro_rules! error_span { + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + error_span!( + target: $target, + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + parent: $parent, + $crate::Level::ERROR, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, parent: $parent:expr, $name:expr) => { + error_span!(target: $target, parent: $parent, $name,) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + error_span!( + parent: $parent, + $name, + $($k $( = $val)*),* + ) + }; + (parent: $parent:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { span!( target: __tokio_trace_module_path!(), - level: $crate::Level::TRACE, + $crate::Level::ERROR, + $name, + $($k $( = $val)*),* + ) + }; + (parent: $parent:expr, $name:expr) => { + error_span!(parent: $parent, $name,) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*,) => { + error_span!( + target: $target, + $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: $target, + $crate::Level::ERROR, $name, + $($k $( = $val)*),* + ) + }; + (target: $target:expr, $name:expr) => { + error_span!(target: $target, $name,) + }; + ($name:expr, $($k:ident $( = $val:expr)*),*,) => { + error_span!( + $name, + $($k $( = $val)*),* + ) + }; + ($name:expr, $($k:ident $( = $val:expr)*),*) => { + span!( + target: __tokio_trace_module_path!(), + $crate::Level::ERROR, + $name, + $($k $( = $val)*),* ) }; + ($name:expr) => {error_span!($name,)}; } /// Constructs a new `Event`. diff --git a/tokio-trace/src/span.rs b/tokio-trace/src/span.rs index 822fa62077b..fa9bbdf0ea0 100644 --- a/tokio-trace/src/span.rs +++ b/tokio-trace/src/span.rs @@ -14,7 +14,7 @@ //! # #[macro_use] extern crate tokio_trace; //! # fn main() { //! let my_var: u64 = 5; -//! let mut my_span = span!("my_span", my_var = &my_var); +//! let mut my_span = span!(tokio_trace::Level::TRACE, "my_span", my_var = &my_var); //! //! my_span.enter(|| { //! // perform some work in the context of `my_span`... @@ -80,7 +80,7 @@ //! # #[macro_use] extern crate tokio_trace; //! # fn main() { //! { -//! span!("my_span").enter(|| { +//! span!(tokio_trace::Level::TRACE, "my_span").enter(|| { //! // perform some work in the context of `my_span`... //! }); // --> Subscriber::exit(my_span) //! @@ -99,7 +99,7 @@ //! # fn main() { //! use tokio_trace::Span; //! -//! let my_span = span!("my_span"); +//! let my_span = span!(tokio_trace::Level::TRACE, "my_span"); //! // Drop the handle to the span. //! drop(my_span); // --> Subscriber::drop_span(my_span) //! # } diff --git a/tokio-trace/test-log-support/tests/log_no_trace.rs b/tokio-trace/test-log-support/tests/log_no_trace.rs index 25eba9f02bb..5188ba4e8a9 100644 --- a/tokio-trace/test-log-support/tests/log_no_trace.rs +++ b/tokio-trace/test-log-support/tests/log_no_trace.rs @@ -41,7 +41,7 @@ fn test_always_log() { info!(message = "hello world;", thingy = 42, other_thingy = 666); last(&a, "hello world; thingy=42 other_thingy=666"); - let mut foo = span!("foo"); + let mut foo = span!(tokio_trace::Level::TRACE, "foo"); last(&a, "foo;"); foo.enter(|| { last(&a, "-> foo"); @@ -51,10 +51,10 @@ fn test_always_log() { }); last(&a, "<- foo"); - span!("foo", bar = 3, baz = false); + span!(tokio_trace::Level::TRACE, "foo", bar = 3, baz = false); last(&a, "foo; bar=3 baz=false"); - let mut span = span!("foo", bar, baz); + let mut span = span!(tokio_trace::Level::TRACE, "foo", bar, baz); span.record("bar", &3); last(&a, "foo; bar=3"); span.record("baz", &"a string"); diff --git a/tokio-trace/tests/macros.rs b/tokio-trace/tests/macros.rs index 903fd2dbf0c..20102082adf 100644 --- a/tokio-trace/tests/macros.rs +++ b/tokio-trace/tests/macros.rs @@ -8,75 +8,262 @@ extern crate tokio_trace; #[test] fn span() { - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 3); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 4,); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, "foo"); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, "bar",); - span!(level: tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 3); - span!(level: tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 4,); - span!(level: tokio_trace::Level::DEBUG, "foo"); - span!(level: tokio_trace::Level::DEBUG, "bar",); - span!("foo", bar = 2, baz = 3); - span!("foo", bar = 2, baz = 4,); - span!("foo"); - span!("bar",); + span!(target: "foo_events", tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 3); + span!(target: "foo_events", tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 4,); + span!(target: "foo_events", tokio_trace::Level::DEBUG, "foo"); + span!(target: "foo_events", tokio_trace::Level::DEBUG, "bar",); + span!(tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 3); + span!(tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 4,); + span!(tokio_trace::Level::TRACE, "foo", bar = 2, baz = 3); + span!(tokio_trace::Level::TRACE, "foo", bar = 2, baz = 4,); + span!(tokio_trace::Level::TRACE, "foo"); + span!(tokio_trace::Level::TRACE, "bar",); +} + +#[test] +fn trace_span() { + trace_span!(target: "foo_events", "foo", bar = 2, baz = 3); + trace_span!(target: "foo_events", "foo", bar = 2, baz = 4,); + trace_span!(target: "foo_events", "foo"); + trace_span!(target: "foo_events", "bar",); + trace_span!("foo", bar = 2, baz = 3); + trace_span!("foo", bar = 2, baz = 4,); + trace_span!("bar"); + trace_span!("bar",); +} + +#[test] +fn debug_span() { + debug_span!(target: "foo_events", "foo", bar = 2, baz = 3); + debug_span!(target: "foo_events", "foo", bar = 2, baz = 4,); + debug_span!(target: "foo_events", "foo"); + debug_span!(target: "foo_events", "bar",); + debug_span!("foo", bar = 2, baz = 3); + debug_span!("foo", bar = 2, baz = 4,); + debug_span!("bar"); + debug_span!("bar",); +} + +#[test] +fn info_span() { + info_span!(target: "foo_events", "foo", bar = 2, baz = 3); + info_span!(target: "foo_events", "foo", bar = 2, baz = 4,); + info_span!(target: "foo_events", "foo"); + info_span!(target: "foo_events", "bar",); + info_span!("foo", bar = 2, baz = 3); + info_span!("foo", bar = 2, baz = 4,); + info_span!("bar"); + info_span!("bar",); +} + +#[test] +fn warn_span() { + warn_span!(target: "foo_events", "foo", bar = 2, baz = 3); + warn_span!(target: "foo_events", "foo", bar = 2, baz = 4,); + warn_span!(target: "foo_events", "foo"); + warn_span!(target: "foo_events", "bar",); + warn_span!("foo", bar = 2, baz = 3); + warn_span!("foo", bar = 2, baz = 4,); + warn_span!("bar"); + warn_span!("bar",); +} + +#[test] +fn error_span() { + error_span!(target: "foo_events", "foo", bar = 2, baz = 3); + error_span!(target: "foo_events", "foo", bar = 2, baz = 4,); + error_span!(target: "foo_events", "foo"); + error_span!(target: "foo_events", "bar",); + error_span!("foo", bar = 2, baz = 3); + error_span!("foo", bar = 2, baz = 4,); + error_span!("bar"); + error_span!("bar",); } #[test] fn span_root() { - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: None, "foo", bar = 2, baz = 3); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: None, "foo", bar = 2, baz = 4,); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: None, "foo"); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: None, "bar",); + span!(target: "foo_events", parent: None, tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 3); + span!(target: "foo_events", parent: None, tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 4,); + span!(target: "foo_events", parent: None, tokio_trace::Level::DEBUG, "foo"); + span!(target: "foo_events", parent: None, tokio_trace::Level::DEBUG, "bar",); span!( - level: tokio_trace::Level::DEBUG, parent: None, + tokio_trace::Level::TRACE, "foo", bar = 2, baz = 3 ); span!( - level: tokio_trace::Level::DEBUG, parent: None, + tokio_trace::Level::TRACE, "foo", bar = 2, baz = 4, ); - span!(level: tokio_trace::Level::DEBUG, parent: None, "foo"); - span!(level: tokio_trace::Level::DEBUG, parent: None, "bar",); - span!(parent: None, "foo", bar = 2, baz = 3); - span!(parent: None, "foo", bar = 2, baz = 4,); - span!(parent: None, "foo"); - span!(parent: None, "bar",); + span!(parent: None, tokio_trace::Level::TRACE, "foo"); + span!(parent: None, tokio_trace::Level::TRACE, "bar",); +} + +#[test] +fn trace_span_root() { + trace_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 3); + trace_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 4,); + trace_span!(target: "foo_events", parent: None, "foo"); + trace_span!(target: "foo_events", parent: None, "bar",); + trace_span!(parent: None, "foo", bar = 2, baz = 3); + trace_span!(parent: None, "foo", bar = 2, baz = 4,); + trace_span!(parent: None, "foo"); + trace_span!(parent: None, "bar",); +} + +#[test] +fn debug_span_root() { + debug_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 3); + debug_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 4,); + debug_span!(target: "foo_events", parent: None, "foo"); + debug_span!(target: "foo_events", parent: None, "bar",); + debug_span!(parent: None, "foo", bar = 2, baz = 3); + debug_span!(parent: None, "foo", bar = 2, baz = 4,); + debug_span!(parent: None, "foo"); + debug_span!(parent: None, "bar",); +} + +#[test] +fn info_span_root() { + info_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 3); + info_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 4,); + info_span!(target: "foo_events", parent: None, "foo"); + info_span!(target: "foo_events", parent: None, "bar",); + info_span!(parent: None, "foo", bar = 2, baz = 3); + info_span!(parent: None, "foo", bar = 2, baz = 4,); + info_span!(parent: None, "foo"); + info_span!(parent: None, "bar",); +} + +#[test] +fn warn_span_root() { + warn_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 3); + warn_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 4,); + warn_span!(target: "foo_events", parent: None, "foo"); + warn_span!(target: "foo_events", parent: None, "bar",); + warn_span!(parent: None, "foo", bar = 2, baz = 3); + warn_span!(parent: None, "foo", bar = 2, baz = 4,); + warn_span!(parent: None, "foo"); + warn_span!(parent: None, "bar",); +} + +#[test] +fn error_span_root() { + error_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 3); + error_span!(target: "foo_events", parent: None, "foo", bar = 2, baz = 4,); + error_span!(target: "foo_events", parent: None, "foo"); + error_span!(target: "foo_events", parent: None, "bar",); + error_span!(parent: None, "foo", bar = 2, baz = 3); + error_span!(parent: None, "foo", bar = 2, baz = 4,); + error_span!(parent: None, "foo"); + error_span!(parent: None, "bar",); } #[test] fn span_with_parent() { - let p = span!("im_a_parent!"); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: &p, "foo", bar = 2, baz = 3); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: &p, "foo", bar = 2, baz = 4,); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: &p, "foo"); - span!(target: "foo_events", level: tokio_trace::Level::DEBUG, parent: &p, "bar",); + let p = span!(tokio_trace::Level::TRACE, "im_a_parent!"); + span!(target: "foo_events", parent: &p, tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 3); + span!(target: "foo_events", parent: &p, tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 4,); + span!(target: "foo_events", parent: &p, tokio_trace::Level::DEBUG, "foo"); + span!(target: "foo_events", parent: &p, tokio_trace::Level::DEBUG, "bar",); + span!( - level: tokio_trace::Level::DEBUG, parent: &p, + tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 3 ); span!( - level: tokio_trace::Level::DEBUG, parent: &p, + tokio_trace::Level::DEBUG, "foo", bar = 2, baz = 4, ); - span!(level: tokio_trace::Level::DEBUG, parent: &p, "foo"); - span!(level: tokio_trace::Level::DEBUG, parent: &p, "bar",); - span!(parent: &p, "foo", bar = 2, baz = 3); - span!(parent: &p, "foo", bar = 2, baz = 4,); - span!(parent: &p, "foo"); - span!(parent: &p, "bar",); + + span!(parent: &p, tokio_trace::Level::DEBUG, "foo"); + span!(parent: &p, tokio_trace::Level::DEBUG, "bar",); +} + +#[test] +fn trace_span_with_parent() { + let p = span!(tokio_trace::Level::TRACE, "im_a_parent!"); + trace_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 3); + trace_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 4,); + trace_span!(target: "foo_events", parent: &p, "foo"); + trace_span!(target: "foo_events", parent: &p, "bar",); + + trace_span!(parent: &p, "foo", bar = 2, baz = 3); + trace_span!(parent: &p, "foo", bar = 2, baz = 4,); + + trace_span!(parent: &p, "foo"); + trace_span!(parent: &p, "bar",); +} + +#[test] +fn debug_span_with_parent() { + let p = span!(tokio_trace::Level::TRACE, "im_a_parent!"); + debug_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 3); + debug_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 4,); + debug_span!(target: "foo_events", parent: &p, "foo"); + debug_span!(target: "foo_events", parent: &p, "bar",); + + debug_span!(parent: &p, "foo", bar = 2, baz = 3); + debug_span!(parent: &p, "foo", bar = 2, baz = 4,); + + debug_span!(parent: &p, "foo"); + debug_span!(parent: &p, "bar",); +} + +#[test] +fn info_span_with_parent() { + let p = span!(tokio_trace::Level::TRACE, "im_a_parent!"); + info_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 3); + info_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 4,); + info_span!(target: "foo_events", parent: &p, "foo"); + info_span!(target: "foo_events", parent: &p, "bar",); + + info_span!(parent: &p, "foo", bar = 2, baz = 3); + info_span!(parent: &p, "foo", bar = 2, baz = 4,); + + info_span!(parent: &p, "foo"); + info_span!(parent: &p, "bar",); +} + +#[test] +fn warn_span_with_parent() { + let p = span!(tokio_trace::Level::TRACE, "im_a_parent!"); + warn_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 3); + warn_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 4,); + warn_span!(target: "foo_events", parent: &p, "foo"); + warn_span!(target: "foo_events", parent: &p, "bar",); + + warn_span!(parent: &p, "foo", bar = 2, baz = 3); + warn_span!(parent: &p, "foo", bar = 2, baz = 4,); + + warn_span!(parent: &p, "foo"); + warn_span!(parent: &p, "bar",); +} + +#[test] +fn error_span_with_parent() { + let p = span!(tokio_trace::Level::TRACE, "im_a_parent!"); + error_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 3); + error_span!(target: "foo_events", parent: &p, "foo", bar = 2, baz = 4,); + error_span!(target: "foo_events", parent: &p, "foo"); + error_span!(target: "foo_events", parent: &p, "bar",); + + error_span!(parent: &p, "foo", bar = 2, baz = 3); + error_span!(parent: &p, "foo", bar = 2, baz = 4,); + + error_span!(parent: &p, "foo"); + error_span!(parent: &p, "bar",); } #[test] diff --git a/tokio-trace/tests/span.rs b/tokio-trace/tests/span.rs index 3ff0d95fed6..bd05116b856 100644 --- a/tokio-trace/tests/span.rs +++ b/tokio-trace/tests/span.rs @@ -13,7 +13,7 @@ fn handles_to_the_same_span_are_equal() { // won't enter any spans in this test, so the subscriber won't actually // expect to see any spans. with_default(subscriber::mock().run(), || { - let foo1 = span!("foo"); + let foo1 = span!(tokio_trace::Level::TRACE, "foo"); let foo2 = foo1.clone(); // Two handles that point to the same span are equal. assert_eq!(foo1, foo2); @@ -25,8 +25,8 @@ fn handles_to_different_spans_are_not_equal() { with_default(subscriber::mock().run(), || { // Even though these spans have the same name and fields, they will have // differing metadata, since they were created on different lines. - let foo1 = span!("foo", bar = 1u64, baz = false); - let foo2 = span!("foo", bar = 1u64, baz = false); + let foo1 = span!(tokio_trace::Level::TRACE, "foo", bar = 1u64, baz = false); + let foo2 = span!(tokio_trace::Level::TRACE, "foo", bar = 1u64, baz = false); assert_ne!(foo1, foo2); }); @@ -37,7 +37,7 @@ fn handles_to_different_spans_with_the_same_metadata_are_not_equal() { // Every time time this function is called, it will return a _new // instance_ of a span with the same metadata, name, and fields. fn make_span() -> Span { - span!("foo", bar = 1u64, baz = false) + span!(tokio_trace::Level::TRACE, "foo", bar = 1u64, baz = false) } with_default(subscriber::mock().run(), || { @@ -62,7 +62,7 @@ fn spans_always_go_to_the_subscriber_that_tagged_them() { let subscriber2 = subscriber::mock().run(); let mut foo = with_default(subscriber1, || { - let mut foo = span!("foo"); + let mut foo = span!(tokio_trace::Level::TRACE, "foo"); foo.enter(|| {}); foo }); @@ -82,7 +82,7 @@ fn spans_always_go_to_the_subscriber_that_tagged_them_even_across_threads() { .done() .run(); let mut foo = with_default(subscriber1, || { - let mut foo = span!("foo"); + let mut foo = span!(tokio_trace::Level::TRACE, "foo"); foo.enter(|| {}); foo }); @@ -107,7 +107,7 @@ fn dropping_a_span_calls_drop_span() { .done() .run_with_handle(); with_default(subscriber, || { - let mut span = span!("foo"); + let mut span = span!(tokio_trace::Level::TRACE, "foo"); span.enter(|| {}); drop(span); }); @@ -125,7 +125,7 @@ fn span_closes_after_event() { .done() .run_with_handle(); with_default(subscriber, || { - span!("foo").enter(|| { + span!(tokio_trace::Level::TRACE, "foo").enter(|| { event!(Level::DEBUG, {}, "my event!"); }); }); @@ -146,10 +146,10 @@ fn new_span_after_event() { .done() .run_with_handle(); with_default(subscriber, || { - span!("foo").enter(|| { + span!(tokio_trace::Level::TRACE, "foo").enter(|| { event!(Level::DEBUG, {}, "my event!"); }); - span!("bar").enter(|| {}); + span!(tokio_trace::Level::TRACE, "bar").enter(|| {}); }); handle.assert_finished(); @@ -166,7 +166,7 @@ fn event_outside_of_span() { .run_with_handle(); with_default(subscriber, || { debug!("my event!"); - span!("foo").enter(|| {}); + span!(tokio_trace::Level::TRACE, "foo").enter(|| {}); }); handle.assert_finished(); @@ -178,7 +178,7 @@ fn cloning_a_span_calls_clone_span() { .clone_span(span::mock().named("foo")) .run_with_handle(); with_default(subscriber, || { - let span = span!("foo"); + let span = span!(tokio_trace::Level::TRACE, "foo"); let _span2 = span.clone(); }); @@ -193,7 +193,7 @@ fn drop_span_when_exiting_dispatchers_context() { .drop_span(span::mock().named("foo")) .run_with_handle(); with_default(subscriber, || { - let span = span!("foo"); + let span = span!(tokio_trace::Level::TRACE, "foo"); let _span2 = span.clone(); drop(span); }); @@ -215,7 +215,7 @@ fn clone_and_drop_span_always_go_to_the_subscriber_that_tagged_the_span() { let subscriber2 = subscriber::mock().done().run(); let mut foo = with_default(subscriber1, || { - let mut foo = span!("foo"); + let mut foo = span!(tokio_trace::Level::TRACE, "foo"); foo.enter(|| {}); foo }); @@ -240,7 +240,7 @@ fn span_closes_when_exited() { .done() .run_with_handle(); with_default(subscriber, || { - let mut foo = span!("foo"); + let mut foo = span!(tokio_trace::Level::TRACE, "foo"); foo.enter(|| {}); @@ -267,7 +267,11 @@ fn moved_field() { .run_with_handle(); with_default(subscriber, || { let from = "my span"; - let mut span = span!("foo", bar = display(format!("hello from {}", from))); + let mut span = span!( + tokio_trace::Level::TRACE, + "foo", + bar = display(format!("hello from {}", from)) + ); span.enter(|| {}); }); @@ -293,7 +297,7 @@ fn borrowed_field() { with_default(subscriber, || { let from = "my span"; let mut message = format!("hello from {}", from); - let mut span = span!("foo", bar = display(&message)); + let mut span = span!(tokio_trace::Level::TRACE, "foo", bar = display(&message)); span.enter(|| { message.insert_str(10, " inside"); }); @@ -339,8 +343,13 @@ fn move_field_out_of_struct() { x: 3.234, y: -1.223, }; - let mut foo = span!("foo", x = debug(pos.x), y = debug(pos.y)); - let mut bar = span!("bar", position = debug(pos)); + let mut foo = span!( + tokio_trace::Level::TRACE, + "foo", + x = debug(pos.x), + y = debug(pos.y) + ); + let mut bar = span!(tokio_trace::Level::TRACE, "bar", position = debug(pos)); foo.enter(|| {}); bar.enter(|| {}); }); @@ -367,7 +376,7 @@ fn add_field_after_new_span() { .run_with_handle(); with_default(subscriber, || { - let mut span = span!("foo", bar = 5, baz); + let mut span = span!(tokio_trace::Level::TRACE, "foo", bar = 5, baz); span.record("baz", &true); span.enter(|| {}) }); @@ -394,7 +403,7 @@ fn add_fields_only_after_new_span() { .run_with_handle(); with_default(subscriber, || { - let mut span = span!("foo", bar, baz); + let mut span = span!(tokio_trace::Level::TRACE, "foo", bar, baz); span.record("bar", &5); span.record("baz", &true); span.enter(|| {}) @@ -416,7 +425,7 @@ fn new_span_with_target_and_log_level() { .run_with_handle(); with_default(subscriber, || { - span!(target: "app_span", level: tokio_trace::Level::DEBUG, "foo"); + span!(target: "app_span", tokio_trace::Level::DEBUG, "foo"); }); handle.assert_finished(); @@ -430,7 +439,7 @@ fn explicit_root_span_is_root() { .run_with_handle(); with_default(subscriber, || { - span!(parent: None, "foo"); + span!(parent: None, tokio_trace::Level::TRACE, "foo"); }); handle.assert_finished(); @@ -447,8 +456,8 @@ fn explicit_root_span_is_root_regardless_of_ctx() { .run_with_handle(); with_default(subscriber, || { - span!("foo").enter(|| { - span!(parent: None, "bar"); + span!(tokio_trace::Level::TRACE, "foo").enter(|| { + span!(parent: None, tokio_trace::Level::TRACE, "bar"); }) }); @@ -464,8 +473,8 @@ fn explicit_child() { .run_with_handle(); with_default(subscriber, || { - let foo = span!("foo"); - span!(parent: foo.id(), "bar"); + let foo = span!(tokio_trace::Level::TRACE, "foo"); + span!(parent: foo.id(), tokio_trace::Level::TRACE, "bar"); }); handle.assert_finished(); @@ -483,8 +492,9 @@ fn explicit_child_regardless_of_ctx() { .run_with_handle(); with_default(subscriber, || { - let foo = span!("foo"); - span!("bar").enter(|| span!(parent: foo.id(), "baz")) + let foo = span!(tokio_trace::Level::TRACE, "foo"); + span!(tokio_trace::Level::TRACE, "bar") + .enter(|| span!(parent: foo.id(), tokio_trace::Level::TRACE, "baz")) }); handle.assert_finished(); @@ -498,7 +508,7 @@ fn contextual_root() { .run_with_handle(); with_default(subscriber, || { - span!("foo"); + span!(tokio_trace::Level::TRACE, "foo"); }); handle.assert_finished(); @@ -519,8 +529,8 @@ fn contextual_child() { .run_with_handle(); with_default(subscriber, || { - span!("foo").enter(|| { - span!("bar"); + span!(tokio_trace::Level::TRACE, "foo").enter(|| { + span!(tokio_trace::Level::TRACE, "bar"); }) }); diff --git a/tokio-trace/tests/subscriber.rs b/tokio-trace/tests/subscriber.rs index eee276ca612..d0a2a314c09 100644 --- a/tokio-trace/tests/subscriber.rs +++ b/tokio-trace/tests/subscriber.rs @@ -36,9 +36,9 @@ fn filters_are_not_reevaluated_for_the_same_span() { with_default(subscriber, move || { // Enter "alice" and then "bob". The dispatcher expects to see "bob" but // not "alice." - let mut alice = span!("alice"); + let mut alice = span!(tokio_trace::Level::TRACE, "alice"); let mut bob = alice.enter(|| { - let mut bob = span!("bob"); + let mut bob = span!(tokio_trace::Level::TRACE, "bob"); bob.enter(|| ()); bob }); @@ -90,9 +90,9 @@ fn filters_are_reevaluated_for_different_call_sites() { with_default(subscriber, move || { // Enter "charlie" and then "dave". The dispatcher expects to see "dave" but // not "charlie." - let mut charlie = span!("charlie"); + let mut charlie = span!(tokio_trace::Level::TRACE, "charlie"); let mut dave = charlie.enter(|| { - let mut dave = span!("dave"); + let mut dave = span!(tokio_trace::Level::TRACE, "dave"); dave.enter(|| {}); dave }); @@ -110,14 +110,14 @@ fn filters_are_reevaluated_for_different_call_sites() { // A different span with the same name has a different call site, so it // should cause the filter to be reapplied. - let mut charlie2 = span!("charlie"); + let mut charlie2 = span!(tokio_trace::Level::TRACE, "charlie"); charlie.enter(|| {}); assert_eq!(charlie_count.load(Ordering::Relaxed), 2); assert_eq!(dave_count.load(Ordering::Relaxed), 1); // But, the filter should not be re-evaluated for the new "charlie" span // when it is re-entered. - charlie2.enter(|| span!("dave").enter(|| {})); + charlie2.enter(|| span!(tokio_trace::Level::TRACE, "dave").enter(|| {})); assert_eq!(charlie_count.load(Ordering::Relaxed), 2); assert_eq!(dave_count.load(Ordering::Relaxed), 2); }); @@ -126,11 +126,11 @@ fn filters_are_reevaluated_for_different_call_sites() { #[test] fn filter_caching_is_lexically_scoped() { pub fn my_great_function() -> bool { - span!("emily").enter(|| true) + span!(tokio_trace::Level::TRACE, "emily").enter(|| true) } pub fn my_other_function() -> bool { - span!("frank").enter(|| true) + span!(tokio_trace::Level::TRACE, "frank").enter(|| true) } let count = Arc::new(AtomicUsize::new(0));