Skip to content
Snippets Groups Projects
Commit a13fda2e authored by Gav Wood's avatar Gav Wood Committed by GitHub
Browse files

Fix telemetry (and a minor cleanup) (#1384)

parent 42c30609
No related merge requests found
......@@ -3810,7 +3810,7 @@ dependencies = [
"slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"slog-scope 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ws 0.7.9 (git+https://github.com/tomusdrw/ws-rs)",
"ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -4627,6 +4627,24 @@ dependencies = [
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ws"
version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
"mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
......@@ -5044,6 +5062,7 @@ dependencies = [
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
"checksum ws 0.7.9 (git+https://github.com/tomusdrw/ws-rs)" = "<none>"
"checksum ws 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "329d3e6dd450a9c5c73024e1047f0be7e24121a68484eb0b5368977bee3cf8c3"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"
......
......@@ -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));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment