Rework telemetry to replace the use of tracing with an object we pass around (#8143)

polkadot companion: paritytech/polkadot#2535
This commit is contained in:
Cecile Tonglet
2021-03-11 11:05:45 +01:00
committed by GitHub
parent 7aaba0c154
commit 8031b6eacb
55 changed files with 1028 additions and 838 deletions
@@ -39,7 +39,7 @@ use sp_runtime::generic::BlockId;
use sp_runtime::traits::{
Block as BlockT, Header as HeaderT, NumberFor, Zero,
};
use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO};
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO};
use crate::{
local_authority_id, CommandOrError, Commit, Config, Error, NewAuthoritySet, Precommit, Prevote,
@@ -445,6 +445,7 @@ pub(crate) struct Environment<Backend, Block: BlockT, C, N: NetworkT<Block>, SC,
pub(crate) voting_rule: VR,
pub(crate) metrics: Option<Metrics>,
pub(crate) justification_sender: Option<GrandpaJustificationSender<Block>>,
pub(crate) telemetry: Option<TelemetryHandle>,
pub(crate) _phantom: PhantomData<Backend>,
}
@@ -891,7 +892,10 @@ where
};
let report_prevote_metrics = |prevote: &Prevote<Block>| {
telemetry!(CONSENSUS_DEBUG; "afg.prevote_issued";
telemetry!(
self.telemetry;
CONSENSUS_DEBUG;
"afg.prevote_issued";
"round" => round,
"target_number" => ?prevote.target_number,
"target_hash" => ?prevote.target_hash,
@@ -950,7 +954,10 @@ where
};
let report_precommit_metrics = |precommit: &Precommit<Block>| {
telemetry!(CONSENSUS_DEBUG; "afg.precommit_issued";
telemetry!(
self.telemetry;
CONSENSUS_DEBUG;
"afg.precommit_issued";
"round" => round,
"target_number" => ?precommit.target_number,
"target_hash" => ?precommit.target_hash,
@@ -1146,6 +1153,7 @@ where
(round, commit).into(),
false,
self.justification_sender.as_ref(),
self.telemetry.clone(),
)
}
@@ -1210,6 +1218,7 @@ pub(crate) fn finalize_block<BE, Block, Client>(
justification_or_commit: JustificationOrCommit<Block>,
initial_sync: bool,
justification_sender: Option<&GrandpaJustificationSender<Block>>,
telemetry: Option<TelemetryHandle>,
) -> Result<(), CommandOrError<Block::Hash, NumberFor<Block>>>
where
Block: BlockT,
@@ -1245,6 +1254,7 @@ where
number,
&is_descendent_of::<Block, _>(&*client, None),
initial_sync,
None,
).map_err(|e| Error::Safety(e.to_string()))?;
// send a justification notification if a sender exists and in case of error log it.
@@ -1320,7 +1330,10 @@ where
warn!(target: "afg", "Error applying finality to block {:?}: {:?}", (hash, number), e);
e
})?;
telemetry!(CONSENSUS_INFO; "afg.finalized_blocks_up_to";
telemetry!(
telemetry;
CONSENSUS_INFO;
"afg.finalized_blocks_up_to";
"number" => ?number, "hash" => ?hash,
);
@@ -1340,7 +1353,10 @@ where
);
}
telemetry!(CONSENSUS_INFO; "afg.generating_new_authority_set";
telemetry!(
telemetry;
CONSENSUS_INFO;
"afg.generating_new_authority_set";
"number" => ?canon_number, "hash" => ?canon_hash,
"authorities" => ?set_ref.to_vec(),
"set_id" => ?new_id,