Improve tracing (#5698)

* Improve tracing implementation

* Enable tracing in runtime interfaces

* Switch to `TRACE` level
This commit is contained in:
Bastian Köcher
2020-04-20 14:37:27 +02:00
committed by GitHub
parent ca1c60c2cf
commit 1d1caed335
18 changed files with 206 additions and 119 deletions
+3 -34
View File
@@ -23,8 +23,9 @@ extern crate self as frame_support;
#[macro_use]
extern crate bitmask;
#[cfg(feature = "std")]
pub extern crate tracing;
#[doc(hidden)]
pub use sp_tracing;
#[cfg(feature = "std")]
pub use serde;
@@ -222,38 +223,6 @@ macro_rules! assert_ok {
}
}
/// Runs given code within a tracing span, measuring it's execution time.
///
/// Has effect only when running in native environment. In WASM, it simply inserts the
/// code in-place, without any metrics added.
#[macro_export]
macro_rules! tracing_span {
($name:expr; $( $code:tt )*) => {
let span = $crate::if_tracing!(
$crate::tracing::span!($crate::tracing::Level::TRACE, $name)
,
()
);
let guard = $crate::if_tracing!(span.enter(), ());
$( $code )*
$crate::sp_std::mem::drop(guard);
$crate::sp_std::mem::drop(span);
}
}
#[macro_export]
#[cfg(feature = "tracing")]
macro_rules! if_tracing {
( $if:expr, $else:expr ) => {{ $if }}
}
#[macro_export]
#[cfg(not(feature = "tracing"))]
macro_rules! if_tracing {
( $if:expr, $else:expr ) => {{ $else }}
}
/// The void type - it cannot exist.
// Oh rust, you crack me up...
#[derive(Clone, Eq, PartialEq, RuntimeDebug)]