macro_rules! within_span {
    (
		$span:expr;
		$( $code:tt )*
	) => { ... };
    (
		$lvl:expr,
		$name:expr;
		$( $code:tt )*
	) => { ... };
}
Expand description

Runs given code within a tracing span, measuring it’s execution time.

If tracing is not enabled, the code is still executed. Pass in level and name or use any valid sp_tracing::Spanfollowe by ; and the code to execute,

Example

sp_tracing::within_span! {
    sp_tracing::Level::TRACE,
    "test-span";
    1 + 1;
    // some other complex code
}

sp_tracing::within_span! {
    sp_tracing::span!(sp_tracing::Level::WARN, "warn-span", you_can_pass="any params");
    1 + 1;
    // some other complex code
}

sp_tracing::within_span! {
    sp_tracing::debug_span!("debug-span", you_can_pass="any params");
    1 + 1;
    // some other complex code
}