mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 08:07:58 +00:00
Improve tracing (#5698)
* Improve tracing implementation * Enable tracing in runtime interfaces * Switch to `TRACE` level
This commit is contained in:
@@ -1030,12 +1030,7 @@ macro_rules! decl_module {
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_initialize(_block_number_not_used: $trait_instance::BlockNumber) -> $return {
|
||||
use $crate::sp_std::if_std;
|
||||
if_std! {
|
||||
use $crate::tracing;
|
||||
let span = tracing::span!(tracing::Level::DEBUG, "on_initialize");
|
||||
let _enter = span.enter();
|
||||
}
|
||||
$crate::sp_tracing::enter_span!("on_initialize");
|
||||
{ $( $impl )* }
|
||||
}
|
||||
}
|
||||
@@ -1051,12 +1046,7 @@ macro_rules! decl_module {
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_initialize($param: $param_ty) -> $return {
|
||||
use $crate::sp_std::if_std;
|
||||
if_std! {
|
||||
use $crate::tracing;
|
||||
let span = tracing::span!(tracing::Level::DEBUG, "on_initialize");
|
||||
let _enter = span.enter();
|
||||
}
|
||||
$crate::sp_tracing::enter_span!("on_initialize");
|
||||
{ $( $impl )* }
|
||||
}
|
||||
}
|
||||
@@ -1082,12 +1072,7 @@ macro_rules! decl_module {
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_runtime_upgrade() -> $return {
|
||||
use $crate::sp_std::if_std;
|
||||
if_std! {
|
||||
use $crate::tracing;
|
||||
let span = tracing::span!(tracing::Level::DEBUG, "on_runtime_upgrade");
|
||||
let _enter = span.enter();
|
||||
}
|
||||
$crate::sp_tracing::enter_span!("on_runtime_upgrade");
|
||||
{ $( $impl )* }
|
||||
}
|
||||
}
|
||||
@@ -1114,12 +1099,7 @@ macro_rules! decl_module {
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_finalize(_block_number_not_used: $trait_instance::BlockNumber) {
|
||||
use $crate::sp_std::if_std;
|
||||
if_std! {
|
||||
use $crate::tracing;
|
||||
let span = tracing::span!(tracing::Level::DEBUG, "on_finalize");
|
||||
let _enter = span.enter();
|
||||
}
|
||||
$crate::sp_tracing::enter_span!("on_finalize");
|
||||
{ $( $impl )* }
|
||||
}
|
||||
}
|
||||
@@ -1135,12 +1115,7 @@ macro_rules! decl_module {
|
||||
for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )*
|
||||
{
|
||||
fn on_finalize($param: $param_ty) {
|
||||
use $crate::sp_std::if_std;
|
||||
if_std! {
|
||||
use $crate::tracing;
|
||||
let span = tracing::span!(tracing::Level::DEBUG, "on_finalize");
|
||||
let _enter = span.enter();
|
||||
}
|
||||
$crate::sp_tracing::enter_span!("on_finalize");
|
||||
{ $( $impl )* }
|
||||
}
|
||||
}
|
||||
@@ -1209,15 +1184,9 @@ macro_rules! decl_module {
|
||||
$vis fn $name(
|
||||
$origin: $origin_ty $(, $param: $param_ty )*
|
||||
) -> $crate::dispatch::DispatchResult {
|
||||
$crate::sp_std::if_std! {
|
||||
use $crate::tracing;
|
||||
let span = tracing::span!(tracing::Level::DEBUG, stringify!($name));
|
||||
let _enter = span.enter();
|
||||
}
|
||||
{
|
||||
{ $( $impl )* }
|
||||
Ok(())
|
||||
}
|
||||
$crate::sp_tracing::enter_span!(stringify!($name));
|
||||
{ $( $impl )* }
|
||||
Ok(())
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1234,13 +1203,8 @@ macro_rules! decl_module {
|
||||
) => {
|
||||
$(#[doc = $doc_attr])*
|
||||
$vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result {
|
||||
use $crate::sp_std::if_std;
|
||||
if_std! {
|
||||
use $crate::tracing;
|
||||
let span = tracing::span!(tracing::Level::DEBUG, stringify!($name));
|
||||
let _enter = span.enter();
|
||||
}
|
||||
{ $( $impl )* }
|
||||
$crate::sp_tracing::enter_span!(stringify!($name));
|
||||
$( $impl )*
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user