Macro tetcore_tracing::within_span[][src]

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 tetcore_tracing::Spanfollowe by ; and the code to execute,

Example

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

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

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