mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Add tracing support to node (#1940)
* drop in tracing to replace log * add structured logging to trace messages * add structured logging to debug messages * add structured logging to info messages * add structured logging to warn messages * add structured logging to error messages * normalize spacing and Display vs Debug * add instrumentation to the various 'fn run' * use explicit tracing module throughout * fix availability distribution test * don't double-print errors * remove further redundancy from logs * fix test errors * fix more test errors * remove unused kv_log_macro * fix unused variable * add tracing spans to collation generation * add tracing spans to av-store * add tracing spans to backing * add tracing spans to bitfield-signing * add tracing spans to candidate-selection * add tracing spans to candidate-validation * add tracing spans to chain-api * add tracing spans to provisioner * add tracing spans to runtime-api * add tracing spans to availability-distribution * add tracing spans to bitfield-distribution * add tracing spans to network-bridge * add tracing spans to collator-protocol * add tracing spans to pov-distribution * add tracing spans to statement-distribution * add tracing spans to overseer * cleanup
This commit is contained in:
committed by
GitHub
parent
94670d8082
commit
e49989971d
@@ -37,7 +37,7 @@ use polkadot_primitives::v1::{CandidateReceipt, CollatorId, Hash, Id as ParaId,
|
||||
use std::{convert::TryFrom, pin::Pin};
|
||||
use thiserror::Error;
|
||||
|
||||
const TARGET: &'static str = "candidate_selection";
|
||||
const LOG_TARGET: &'static str = "candidate_selection";
|
||||
|
||||
struct CandidateSelectionJob {
|
||||
sender: mpsc::Sender<FromJob>,
|
||||
@@ -134,6 +134,7 @@ impl JobTrait for CandidateSelectionJob {
|
||||
/// Run a job for the parent block indicated
|
||||
//
|
||||
// this function is in charge of creating and executing the job's main loop
|
||||
#[tracing::instrument(skip(_relay_parent, _run_args, metrics, receiver, sender), fields(subsystem = LOG_TARGET))]
|
||||
fn run(
|
||||
_relay_parent: Hash,
|
||||
_run_args: Self::RunArgs,
|
||||
@@ -196,6 +197,7 @@ impl CandidateSelectionJob {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
|
||||
async fn handle_collation(
|
||||
&mut self,
|
||||
relay_parent: Hash,
|
||||
@@ -212,10 +214,10 @@ impl CandidateSelectionJob {
|
||||
).await {
|
||||
Ok(response) => response,
|
||||
Err(err) => {
|
||||
log::warn!(
|
||||
target: TARGET,
|
||||
"failed to get collation from collator protocol subsystem: {:?}",
|
||||
err
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
err = ?err,
|
||||
"failed to get collation from collator protocol subsystem",
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -230,35 +232,36 @@ impl CandidateSelectionJob {
|
||||
)
|
||||
.await
|
||||
{
|
||||
Err(err) => log::warn!(target: TARGET, "failed to second a candidate: {:?}", err),
|
||||
Err(err) => tracing::warn!(target: LOG_TARGET, err = ?err, "failed to second a candidate"),
|
||||
Ok(()) => self.seconded_candidate = Some(collator_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
|
||||
async fn handle_invalid(&mut self, candidate_receipt: CandidateReceipt) {
|
||||
let received_from = match &self.seconded_candidate {
|
||||
Some(peer) => peer,
|
||||
None => {
|
||||
log::warn!(
|
||||
target: TARGET,
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
"received invalidity notice for a candidate we don't remember seconding"
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
log::info!(
|
||||
target: TARGET,
|
||||
"received invalidity note for candidate {:?}",
|
||||
candidate_receipt
|
||||
tracing::info!(
|
||||
target: LOG_TARGET,
|
||||
candidate_receipt = ?candidate_receipt,
|
||||
"received invalidity note for candidate",
|
||||
);
|
||||
|
||||
let result =
|
||||
if let Err(err) = forward_invalidity_note(received_from, &mut self.sender).await {
|
||||
log::warn!(
|
||||
target: TARGET,
|
||||
"failed to forward invalidity note: {:?}",
|
||||
err
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
err = ?err,
|
||||
"failed to forward invalidity note",
|
||||
);
|
||||
Err(())
|
||||
} else {
|
||||
@@ -271,6 +274,7 @@ impl CandidateSelectionJob {
|
||||
// get a collation from the Collator Protocol subsystem
|
||||
//
|
||||
// note that this gets an owned clone of the sender; that's becuase unlike `forward_invalidity_note`, it's expected to take a while longer
|
||||
#[tracing::instrument(level = "trace", skip(sender), fields(subsystem = LOG_TARGET))]
|
||||
async fn get_collation(
|
||||
relay_parent: Hash,
|
||||
para_id: ParaId,
|
||||
@@ -305,7 +309,7 @@ async fn second_candidate(
|
||||
.await
|
||||
{
|
||||
Err(err) => {
|
||||
log::warn!(target: TARGET, "failed to send a seconding message");
|
||||
tracing::warn!(target: LOG_TARGET, err = ?err, "failed to send a seconding message");
|
||||
metrics.on_second(Err(()));
|
||||
Err(err.into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user