Macro sp_tracing::enter_span

source ·
macro_rules! enter_span {
    ( $span:expr ) => { ... };
    ( $lvl:expr, $name:expr ) => { ... };
}
Expand description

Enter a span.

The span will be valid, until the scope is left. Use either level and name or pass in any valid sp_tracing::Span for extended usage. The span will be exited on drop – which is at the end of the block or to the next enter_span! calls, as this overwrites the local variable. For nested usage or to ensure the span closes at certain time either put it into a block or use within_span!

§Example

sp_tracing::enter_span!(sp_tracing::Level::TRACE, "test-span");
// previous will be dropped here
sp_tracing::enter_span!(
	sp_tracing::span!(sp_tracing::Level::DEBUG, "debug-span", params="value"));
sp_tracing::enter_span!(sp_tracing::info_span!("info-span",  params="value"));

{
		sp_tracing::enter_span!(sp_tracing::Level::TRACE, "outer-span");
		{
			sp_tracing::enter_span!(sp_tracing::Level::TRACE, "inner-span");
			// ..
		}  // inner span exists here
	} // outer span exists here