mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 02:21:14 +00:00
Fix telemetry (and a minor cleanup) (#1384)
This commit is contained in:
@@ -97,15 +97,11 @@ pub struct CoreParams {
|
||||
#[structopt(long = "name", value_name = "NAME")]
|
||||
name: Option<String>,
|
||||
|
||||
/// Should connect to the Substrate telemetry server (telemetry is off by default on local chains)
|
||||
#[structopt(short = "t", long = "telemetry")]
|
||||
telemetry: bool,
|
||||
|
||||
/// Should not connect to the Substrate telemetry server (telemetry is on by default on global chains)
|
||||
#[structopt(long = "no-telemetry")]
|
||||
no_telemetry: bool,
|
||||
|
||||
/// The URL of the telemetry server. Implies --telemetry
|
||||
/// The URL of the telemetry server to connect to
|
||||
#[structopt(long = "telemetry-url", value_name = "TELEMETRY_URL")]
|
||||
telemetry_url: Option<String>,
|
||||
|
||||
|
||||
@@ -252,31 +252,28 @@ impl<Components: components::Components> Service<Components> {
|
||||
)?;
|
||||
|
||||
// Telemetry
|
||||
let telemetry = match config.telemetry_url.clone() {
|
||||
Some(url) => {
|
||||
let is_authority = config.roles == Roles::AUTHORITY;
|
||||
let pubkey = format!("{}", public_key);
|
||||
let name = config.name.clone();
|
||||
let impl_name = config.impl_name.to_owned();
|
||||
let version = version.clone();
|
||||
let chain_name = config.chain_spec.name().to_owned();
|
||||
Some(Arc::new(tel::init_telemetry(tel::TelemetryConfig {
|
||||
url: url,
|
||||
on_connect: Box::new(move || {
|
||||
telemetry!("system.connected";
|
||||
"name" => name.clone(),
|
||||
"implementation" => impl_name.clone(),
|
||||
"version" => version.clone(),
|
||||
"config" => "",
|
||||
"chain" => chain_name.clone(),
|
||||
"pubkey" => &pubkey,
|
||||
"authority" => is_authority
|
||||
);
|
||||
}),
|
||||
})))
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
let telemetry = config.telemetry_url.clone().map(|url| {
|
||||
let is_authority = config.roles == Roles::AUTHORITY;
|
||||
let pubkey = format!("{}", public_key);
|
||||
let name = config.name.clone();
|
||||
let impl_name = config.impl_name.to_owned();
|
||||
let version = version.clone();
|
||||
let chain_name = config.chain_spec.name().to_owned();
|
||||
Arc::new(tel::init_telemetry(tel::TelemetryConfig {
|
||||
url: url,
|
||||
on_connect: Box::new(move || {
|
||||
telemetry!("system.connected";
|
||||
"name" => name.clone(),
|
||||
"implementation" => impl_name.clone(),
|
||||
"version" => version.clone(),
|
||||
"config" => "",
|
||||
"chain" => chain_name.clone(),
|
||||
"pubkey" => &pubkey,
|
||||
"authority" => is_authority
|
||||
);
|
||||
}),
|
||||
}))
|
||||
});
|
||||
|
||||
Ok(Service {
|
||||
client,
|
||||
|
||||
@@ -12,4 +12,4 @@ slog = "^2"
|
||||
slog-json = "^2"
|
||||
slog-async = "^2"
|
||||
slog-scope = "^4"
|
||||
ws = { git = "https://github.com/tomusdrw/ws-rs" }
|
||||
ws = { version = "^0.7", features = ["ssl"] }
|
||||
|
||||
@@ -66,7 +66,7 @@ pub fn init_telemetry(config: TelemetryConfig) -> slog_scope::GlobalLoggerGuard
|
||||
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
trace!(target: "telemetry", "Connecting to Telemetry...");
|
||||
trace!(target: "telemetry", "Connecting to Telemetry... {:?}", config.url);
|
||||
let _ = ws::connect(config.url.as_str(), |out| Connection::new(out, &*out_sync, &config));
|
||||
|
||||
thread::sleep(time::Duration::from_millis(5000));
|
||||
|
||||
Reference in New Issue
Block a user