Add more metrics to the import queue (#7207)

This commit is contained in:
Pierre Krieger
2020-09-24 21:11:29 +02:00
committed by GitHub
parent 937fb34bd2
commit 1b350a050c
3 changed files with 53 additions and 3 deletions
@@ -292,6 +292,7 @@ impl<B: BlockT, Transaction: Send> BlockImportWorker<B, Transaction> {
number: NumberFor<B>,
finality_proof: Vec<u8>
) {
let started = wasm_timer::Instant::now();
let result = self.finality_proof_import.as_mut().map(|finality_proof_import| {
finality_proof_import.import_finality_proof(hash, number, finality_proof, verifier)
.map_err(|e| {
@@ -305,6 +306,10 @@ impl<B: BlockT, Transaction: Send> BlockImportWorker<B, Transaction> {
})
}).unwrap_or(Err(()));
if let Some(metrics) = self.metrics.as_ref() {
metrics.finality_proof_import_time.observe(started.elapsed().as_secs_f64());
}
trace!(target: "sync", "Imported finality proof for {}/{}", number, hash);
self.result_sender.finality_proof_imported(who, (hash, number), result);
}
@@ -316,6 +321,7 @@ impl<B: BlockT, Transaction: Send> BlockImportWorker<B, Transaction> {
number: NumberFor<B>,
justification: Justification
) {
let started = wasm_timer::Instant::now();
let success = self.justification_import.as_mut().map(|justification_import| {
justification_import.import_justification(hash, number, justification)
.map_err(|e| {
@@ -331,6 +337,10 @@ impl<B: BlockT, Transaction: Send> BlockImportWorker<B, Transaction> {
}).is_ok()
}).unwrap_or(false);
if let Some(metrics) = self.metrics.as_ref() {
metrics.justification_import_time.observe(started.elapsed().as_secs_f64());
}
self.result_sender.justification_imported(who, &hash, number, success);
}
}