#[macro_export]
macro_rules! instrument_rules_with_spans {
(target: $target:expr, $lvl:expr, options: $options:expr, state: $state:expr, $($fields:tt)*) => {{
let options = $options;
let span_create_fn = std::sync::Arc::new(move |rule_name: &str| {
tracing::span!(
target: $target,
$lvl,
"Rule",
otel.name = rule_name,
datafusion.plan_diff = tracing::field::Empty,
$($fields)*
)
});
let phase_span_create_fn = std::sync::Arc::new(move |phase_name: &str| {
tracing::span!(
target: $target,
$lvl,
"Phase",
otel.name = phase_name,
datafusion.effective_rules = tracing::field::Empty,
datafusion.plan_diff = tracing::field::Empty,
datafusion.optimizer.pass = tracing::field::Empty,
datafusion.optimizer.max_passes = tracing::field::Empty
)
});
$crate::instrument_session_state($state, options, span_create_fn, phase_span_create_fn, $lvl)
}};
(target: $target:expr, $lvl:expr, options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_spans!(target: $target, $lvl, options: $options, state: $state,)
};
($lvl:expr, options: $options:expr, state: $state:expr, $($fields:tt)*) => {
$crate::instrument_rules_with_spans!(target: module_path!(), $lvl, options: $options, state: $state, $($fields)*)
};
($lvl:expr, options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_spans!(target: module_path!(), $lvl, options: $options, state: $state)
};
}
#[macro_export]
macro_rules! instrument_rules_with_trace_spans {
(target: $target:expr, options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_spans!(
target: $target,
tracing::Level::TRACE,
options: $options,
state: $state,
$($field)*
)
};
(options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_trace_spans!(target: module_path!(), options: $options, state: $state, $($field)*)
};
(target: $target:expr, options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_trace_spans!(target: $target, options: $options, state: $state,)
};
(options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_trace_spans!(target: module_path!(), options: $options, state: $state)
};
}
#[macro_export]
macro_rules! instrument_rules_with_debug_spans {
(target: $target:expr, options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_spans!(
target: $target,
tracing::Level::DEBUG,
options: $options,
state: $state,
$($field)*
)
};
(options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_debug_spans!(target: module_path!(), options: $options, state: $state, $($field)*)
};
(target: $target:expr, options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_debug_spans!(target: $target, options: $options, state: $state,)
};
(options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_debug_spans!(target: module_path!(), options: $options, state: $state)
};
}
#[macro_export]
macro_rules! instrument_rules_with_info_spans {
(target: $target:expr, options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_spans!(
target: $target,
tracing::Level::INFO,
options: $options,
state: $state,
$($field)*
)
};
(options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_info_spans!(target: module_path!(), options: $options, state: $state, $($field)*)
};
(target: $target:expr, options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_info_spans!(target: $target, options: $options, state: $state,)
};
(options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_info_spans!(target: module_path!(), options: $options, state: $state)
};
}
#[macro_export]
macro_rules! instrument_rules_with_warn_spans {
(target: $target:expr, options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_spans!(
target: $target,
tracing::Level::WARN,
options: $options,
state: $state,
$($field)*
)
};
(options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_warn_spans!(target: module_path!(), options: $options, state: $state, $($field)*)
};
(target: $target:expr, options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_warn_spans!(target: $target, options: $options, state: $state,)
};
(options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_warn_spans!(target: module_path!(), options: $options, state: $state)
};
}
#[macro_export]
macro_rules! instrument_rules_with_error_spans {
(target: $target:expr, options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_spans!(
target: $target,
tracing::Level::ERROR,
options: $options,
state: $state,
$($field)*
)
};
(options: $options:expr, state: $state:expr, $($field:tt)*) => {
$crate::instrument_rules_with_error_spans!(target: module_path!(), options: $options, state: $state, $($field)*)
};
(target: $target:expr, options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_error_spans!(target: $target, options: $options, state: $state,)
};
(options: $options:expr, state: $state:expr) => {
$crate::instrument_rules_with_error_spans!(target: module_path!(), options: $options, state: $state)
};
}