diff --git a/substrate/frame/support/procedural/src/pallet/expand/call.rs b/substrate/frame/support/procedural/src/pallet/expand/call.rs index 137e055405a38996e76d767d300ec6e8f7edc8e3..295cf14d37f0453cb42b376eb0deb8f14bf1e6ba 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/call.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/call.rs @@ -162,9 +162,13 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { ) -> #frame_support::dispatch::DispatchResultWithPostInfo { match self { #( - Self::#fn_name( #( #args_name, )* ) => + Self::#fn_name( #( #args_name, )* ) => { + #frame_support::sp_tracing::enter_span!( + #frame_support::sp_tracing::trace_span!(stringify!(#fn_name)) + ); <#pallet_ident<#type_use_gen>>::#fn_name(origin, #( #args_name, )* ) - .map(Into::into).map_err(Into::into), + .map(Into::into).map_err(Into::into) + }, )* Self::__Ignore(_, _) => { let _ = origin; // Use origin for empty Call enum diff --git a/substrate/frame/support/procedural/src/pallet/expand/hooks.rs b/substrate/frame/support/procedural/src/pallet/expand/hooks.rs index 3976f2c602dde45ad464b53ba779bd873054388e..2d12d5ecf9d46a8771467fb29d40c18271793826 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/hooks.rs @@ -55,6 +55,9 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { for #pallet_ident<#type_use_gen> #where_clause { fn on_finalize(n: <T as #frame_system::Config>::BlockNumber) { + #frame_support::sp_tracing::enter_span!( + #frame_support::sp_tracing::trace_span!("on_finalize") + ); < Self as #frame_support::traits::Hooks< <T as #frame_system::Config>::BlockNumber @@ -86,6 +89,9 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { fn on_initialize( n: <T as #frame_system::Config>::BlockNumber ) -> #frame_support::weights::Weight { + #frame_support::sp_tracing::enter_span!( + #frame_support::sp_tracing::trace_span!("on_initialize") + ); < Self as #frame_support::traits::Hooks< <T as #frame_system::Config>::BlockNumber @@ -99,6 +105,10 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { for #pallet_ident<#type_use_gen> #where_clause { fn on_runtime_upgrade() -> #frame_support::weights::Weight { + #frame_support::sp_tracing::enter_span!( + #frame_support::sp_tracing::trace_span!("on_runtime_update") + ); + // log info about the upgrade. let new_storage_version = #frame_support::crate_to_pallet_version!(); let pallet_name = < diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index d0d034a55f5029b79a0dc93a3d5f6fd3bf0dfc62..220e7a06bdf3146cd1c4eb24b1889c9c8966c310 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -1229,6 +1229,9 @@ pub mod pallet_prelude { /// NOTE: OnRuntimeUpgrade is implemented with `Hooks::on_runtime_upgrade` and some additional /// logic. E.g. logic to write pallet version into storage. /// +/// NOTE: The macro also adds some tracing logic when implementing the above traits. The following +/// hooks emit traces: `on_initialize`, `on_finalize` and `on_runtime_upgrade`. +/// /// # Call: `#[pallet::call]` mandatory /// /// Implementation of pallet dispatchables.