mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
Add instrumentation, with performance profiling capability (#4132)
* Implement instrumentation for performance profiling * Add profiling to runtime functions declared in `decl_module` inc. `on_initialize` and `on_finalize` * Remove changes * add docs, tidy up * fix versions * fix copyright date * switch to hashmap and instant * update example * update example * implement receiver for logger and make default * fix comment * use `if_std!` macro * remove whitespace * fix whitespace * fix nits
This commit is contained in:
committed by
Gavin Wood
parent
082c58176e
commit
9cc16e539e
@@ -35,7 +35,7 @@ use futures03::{
|
||||
StreamExt as _, TryStreamExt as _,
|
||||
};
|
||||
use keystore::{Store as Keystore};
|
||||
use log::{info, warn};
|
||||
use log::{info, warn, error};
|
||||
use network::{FinalityProofProvider, OnDemand, NetworkService, NetworkStateInfo, DhtEvent};
|
||||
use network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpecialization};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
@@ -1130,6 +1130,17 @@ ServiceBuilder<
|
||||
telemetry
|
||||
});
|
||||
|
||||
// Instrumentation
|
||||
if let Some(tracing_targets) = config.tracing_targets.as_ref() {
|
||||
let subscriber = substrate_tracing::ProfilingSubscriber::new(
|
||||
config.tracing_receiver, tracing_targets
|
||||
);
|
||||
match tracing::subscriber::set_global_default(subscriber) {
|
||||
Ok(_) => (),
|
||||
Err(e) => error!(target: "tracing", "Unable to set global default subscriber {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Service {
|
||||
client,
|
||||
network,
|
||||
|
||||
@@ -98,6 +98,10 @@ pub struct Configuration<C, G, E = NoExtension> {
|
||||
///
|
||||
/// Should only be set when `node` is running development mode.
|
||||
pub dev_key_seed: Option<String>,
|
||||
/// Tracing targets
|
||||
pub tracing_targets: Option<String>,
|
||||
/// Tracing receiver
|
||||
pub tracing_receiver: substrate_tracing::TracingReceiver,
|
||||
}
|
||||
|
||||
/// Configuration of the database of the client.
|
||||
@@ -156,6 +160,8 @@ impl<C, G, E> Configuration<C, G, E> where
|
||||
disable_grandpa: false,
|
||||
keystore_password: None,
|
||||
dev_key_seed: None,
|
||||
tracing_targets: Default::default(),
|
||||
tracing_receiver: Default::default(),
|
||||
};
|
||||
configuration.network.boot_nodes = configuration.chain_spec.boot_nodes().to_vec();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user