diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 37aeca5892..5746491431 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -5905,6 +5905,7 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.10.2", + "rand 0.7.3", "sc-block-builder", "sc-client-api", "sc-executor", diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index bf93cdfde8..a28418b9a2 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -28,6 +28,7 @@ sp-keyring = { version = "2.0.0-dev", path = "../primitives/keyring" } kvdb = "0.5.0" log = { version = "0.4.8" } parking_lot = "0.10.0" +rand = "0.7.3" sp-core = { version = "2.0.0-dev", path = "../primitives/core" } sp-std = { version = "2.0.0-dev", path = "../primitives/std" } sp-version = { version = "2.0.0-dev", path = "../primitives/version" } diff --git a/substrate/client/src/client.rs b/substrate/client/src/client.rs index 34f4ffbb8d..a71d6bf964 100644 --- a/substrate/client/src/client.rs +++ b/substrate/client/src/client.rs @@ -613,11 +613,20 @@ impl Client where if let Ok(ImportResult::Imported(ref aux)) = result { if aux.is_new_best { - telemetry!(SUBSTRATE_INFO; "block.import"; - "height" => height, - "best" => ?hash, - "origin" => ?origin - ); + use rand::Rng; + + // don't send telemetry block import events during initial sync for every + // block to avoid spamming the telemetry server, these events will be randomly + // sent at a rate of 1/10. + if origin != BlockOrigin::NetworkInitialSync || + rand::thread_rng().gen_bool(0.1) + { + telemetry!(SUBSTRATE_INFO; "block.import"; + "height" => height, + "best" => ?hash, + "origin" => ?origin + ); + } } }