mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
client: avoid spamming telemetry on initial sync (#5651)
This commit is contained in:
@@ -613,11 +613,20 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> 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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user