mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 22:21:07 +00:00
Telemetry improvements (#1886)
* Fix typo * Support multiple telemetry endpoints and verbosity levels * Bump substrate-telemetry version * Telemetrify Aura consensus * Telemetrify Grandpa * Fix CI version conflicts * Implement style remarks * Fix fixture * Implement style remarks * Clone only when necessary * Get rid of Arc for URL * Handle connection issues better
This commit is contained in:
committed by
Bastian Köcher
parent
8a72abffdd
commit
90e5c5ddfb
@@ -25,7 +25,7 @@ use tokio::timer::Interval;
|
||||
use sysinfo::{get_current_pid, ProcessExt, System, SystemExt};
|
||||
use network::{SyncState, SyncProvider};
|
||||
use client::{backend::Backend, BlockchainEvents};
|
||||
use substrate_telemetry::telemetry;
|
||||
use substrate_telemetry::*;
|
||||
use log::{debug, info, warn};
|
||||
|
||||
use runtime_primitives::generic::BlockId;
|
||||
@@ -86,6 +86,7 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
|
||||
} else { (0.0, 0) };
|
||||
|
||||
telemetry!(
|
||||
SUBSTRATE_INFO;
|
||||
"system.interval";
|
||||
"status" => format!("{}{}", status, target),
|
||||
"peers" => num_peers,
|
||||
@@ -144,7 +145,7 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
|
||||
let txpool = service.transaction_pool();
|
||||
let display_txpool_import = txpool.import_notification_stream().for_each(move |_| {
|
||||
let status = txpool.status();
|
||||
telemetry!("txpool.import"; "ready" => status.ready, "future" => status.future);
|
||||
telemetry!(SUBSTRATE_INFO; "txpool.import"; "ready" => status.ready, "future" => status.future);
|
||||
Ok(())
|
||||
});
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ use log::info;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use futures::Future;
|
||||
use substrate_telemetry::TelemetryEndpoints;
|
||||
|
||||
const MAX_NODE_NAME_LENGTH: usize = 32;
|
||||
|
||||
@@ -401,9 +402,9 @@ where
|
||||
|
||||
// Override telemetry
|
||||
if cli.no_telemetry {
|
||||
config.telemetry_url = None;
|
||||
} else if let Some(url) = cli.telemetry_url {
|
||||
config.telemetry_url = Some(url);
|
||||
config.telemetry_endpoints = None;
|
||||
} else if !cli.telemetry_endpoints.is_empty() {
|
||||
config.telemetry_endpoints = Some(TelemetryEndpoints::new(cli.telemetry_endpoints));
|
||||
}
|
||||
|
||||
Ok(config)
|
||||
|
||||
@@ -173,9 +173,11 @@ pub struct RunCmd {
|
||||
#[structopt(long = "no-telemetry")]
|
||||
pub no_telemetry: bool,
|
||||
|
||||
/// The URL of the telemetry server to connect to
|
||||
#[structopt(long = "telemetry-url", value_name = "TELEMETRY_URL")]
|
||||
pub telemetry_url: Option<String>,
|
||||
/// The URL of the telemetry server to connect to. This flag can be passed multiple times
|
||||
/// as a mean to specify multiple telemetry endpoints. Verbosity levels range from 0-9, with
|
||||
/// 0 denoting the least verbosity. If no verbosity level is specified the default is 0.
|
||||
#[structopt(long = "telemetry-url", value_name = "URL VERBOSITY", parse(try_from_str = "parse_telemetry_endpoints"))]
|
||||
pub telemetry_endpoints: Vec<(String, u8)>,
|
||||
|
||||
/// The means of execution used when calling into the runtime while syncing blocks.
|
||||
#[structopt(
|
||||
@@ -239,6 +241,21 @@ pub struct RunCmd {
|
||||
pub pool_config: TransactionPoolParams,
|
||||
}
|
||||
|
||||
/// Default to verbosity level 0, if none is provided.
|
||||
fn parse_telemetry_endpoints(s: &str) -> Result<(String, u8), Box<std::error::Error>> {
|
||||
let pos = s.find(' ');
|
||||
match pos {
|
||||
None => {
|
||||
Ok((s.to_owned(), 0))
|
||||
},
|
||||
Some(pos_) => {
|
||||
let verbosity = s[pos_ + 1..].parse()?;
|
||||
let url = s[..pos_].parse()?;
|
||||
Ok((url, verbosity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl_augment_clap!(RunCmd);
|
||||
impl_get_log_filter!(RunCmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user