vortex_layout/macros.rs
1/// A macro for optionally instrumenting a future, if tracing feature is enabled.
2#[macro_export]
3macro_rules! instrument {
4 ($span_name:expr, $expr:expr) => {
5 instrument!($span_name, [], $expr)
6 };
7 ($span_name:expr, [ $($key:ident = $value:expr),* $(,)? ], $expr:expr) => {
8 {
9 let task = $expr;
10 #[cfg(feature = "tracing")]
11 {
12 use tracing_futures::Instrument;
13 task.instrument(tracing::info_span!(
14 $span_name,
15 $($key = $value,)*
16 ))
17 }
18 #[cfg(not(feature = "tracing"))]
19 {
20 task
21 }
22 }
23 };
24}