mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
observability: tracing gum, automatically cross ref traceID (#5079)
* add some gum * bump expander * gum * fix all remaining issues * last fixup * Update node/gum/proc-macro/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * change * netowrk * fixins * chore * allow optional fmt str + args, prep for expr as kv field * tracing -> gum rename fallout * restrict further * allow multiple levels of field accesses * another round of docs and a slip of the pen * update ADR * fixup lock fiel * use target: instead of target= * minors * fix * chore * Update node/gum/README.md Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
fa359fd1f7
commit
d631f1dea8
@@ -87,8 +87,8 @@ pub fn log_error(result: Result<()>, ctx: &'static str) -> std::result::Result<(
|
||||
Err(jfyi) => {
|
||||
match jfyi {
|
||||
JfyiError::RequestedUnannouncedCandidate(_, _) =>
|
||||
tracing::warn!(target: LOG_TARGET, error = %jfyi, ctx),
|
||||
_ => tracing::debug!(target: LOG_TARGET, error = %jfyi, ctx),
|
||||
gum::warn!(target: LOG_TARGET, error = %jfyi, ctx),
|
||||
_ => gum::debug!(target: LOG_TARGET, error = %jfyi, ctx),
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
|
||||
@@ -169,7 +169,7 @@ impl VcPerPeerTracker {
|
||||
/// based on a message that we have sent it from our local pool.
|
||||
fn note_local(&mut self, h: CandidateHash) {
|
||||
if !note_hash(&mut self.local_observed, h) {
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
"Statement distribution is erroneously attempting to distribute more \
|
||||
than {} candidate(s) per validator index. Ignoring",
|
||||
@@ -703,7 +703,7 @@ impl ActiveHeadData {
|
||||
CompactStatement::Seconded(h) => {
|
||||
let seconded_so_far = self.seconded_counts.entry(validator_index).or_insert(0);
|
||||
if *seconded_so_far >= VC_THRESHOLD {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
?statement,
|
||||
@@ -714,7 +714,7 @@ impl ActiveHeadData {
|
||||
|
||||
self.candidates.insert(h);
|
||||
if let Some(old) = self.statements.insert(comparator.clone(), statement) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
statement = ?old,
|
||||
@@ -724,7 +724,7 @@ impl ActiveHeadData {
|
||||
} else {
|
||||
*seconded_so_far += 1;
|
||||
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
statement = ?self.statements.last().expect("Just inserted").1,
|
||||
@@ -741,7 +741,7 @@ impl ActiveHeadData {
|
||||
},
|
||||
CompactStatement::Valid(h) => {
|
||||
if !self.candidates.contains(&h) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
?statement,
|
||||
@@ -751,7 +751,7 @@ impl ActiveHeadData {
|
||||
}
|
||||
|
||||
if let Some(old) = self.statements.insert(comparator.clone(), statement) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
statement = ?old,
|
||||
@@ -759,7 +759,7 @@ impl ActiveHeadData {
|
||||
);
|
||||
NotedStatement::UsefulButKnown
|
||||
} else {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
statement = ?self.statements.last().expect("Just inserted").1,
|
||||
@@ -795,7 +795,7 @@ impl ActiveHeadData {
|
||||
CompactStatement::Seconded(_) => {
|
||||
let seconded_so_far = self.seconded_counts.get(&validator_index).unwrap_or(&0);
|
||||
if *seconded_so_far >= VC_THRESHOLD {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
?statement,
|
||||
@@ -805,7 +805,7 @@ impl ActiveHeadData {
|
||||
}
|
||||
|
||||
if self.statements.contains_key(&comparator) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
?statement,
|
||||
@@ -816,7 +816,7 @@ impl ActiveHeadData {
|
||||
},
|
||||
CompactStatement::Valid(h) => {
|
||||
if !self.candidates.contains(&h) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
?statement,
|
||||
@@ -826,7 +826,7 @@ impl ActiveHeadData {
|
||||
}
|
||||
|
||||
if self.statements.contains_key(&comparator) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?validator_index,
|
||||
?statement,
|
||||
@@ -1033,7 +1033,7 @@ async fn circulate_statement<'a>(
|
||||
// Send all these peers the initial statement.
|
||||
if !peers_to_send.is_empty() {
|
||||
let payload = statement_message(relay_parent, stored.statement.clone());
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?peers_to_send,
|
||||
?relay_parent,
|
||||
@@ -1071,7 +1071,7 @@ async fn send_statements_about(
|
||||
peer_data.send(&relay_parent, &fingerprint);
|
||||
let payload = statement_message(relay_parent, statement.statement.clone());
|
||||
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?peer,
|
||||
?relay_parent,
|
||||
@@ -1106,7 +1106,7 @@ async fn send_statements(
|
||||
peer_data.send(&relay_parent, &fingerprint);
|
||||
let payload = statement_message(relay_parent, statement.statement.clone());
|
||||
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?peer,
|
||||
?relay_parent,
|
||||
@@ -1244,7 +1244,7 @@ async fn launch_request(
|
||||
|
||||
let result = ctx.spawn("large-statement-fetcher", task.boxed());
|
||||
if let Err(err) = result {
|
||||
tracing::error!(target: LOG_TARGET, ?err, "Spawning task failed.");
|
||||
gum::error!(target: LOG_TARGET, ?err, "Spawning task failed.");
|
||||
return None
|
||||
}
|
||||
let available_peers = {
|
||||
@@ -1312,7 +1312,7 @@ async fn handle_incoming_message<'a>(
|
||||
let active_head = match active_heads.get_mut(&relay_parent) {
|
||||
Some(h) => h,
|
||||
None => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
%relay_parent,
|
||||
"our view out-of-sync with active heads; head not found",
|
||||
@@ -1324,13 +1324,7 @@ async fn handle_incoming_message<'a>(
|
||||
|
||||
if let protocol_v1::StatementDistributionMessage::LargeStatement(_) = message {
|
||||
if let Err(rep) = peer_data.receive_large_statement(&relay_parent) {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer,
|
||||
?message,
|
||||
?rep,
|
||||
"Unexpected large statement.",
|
||||
);
|
||||
gum::debug!(target: LOG_TARGET, ?peer, ?message, ?rep, "Unexpected large statement.",);
|
||||
report_peer(ctx, peer, rep).await;
|
||||
return None
|
||||
}
|
||||
@@ -1355,7 +1349,7 @@ async fn handle_incoming_message<'a>(
|
||||
// reputation change flood.
|
||||
let unexpected_count = peer_data.receive_unexpected(&relay_parent);
|
||||
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?relay_parent,
|
||||
?peer,
|
||||
@@ -1406,12 +1400,7 @@ async fn handle_incoming_message<'a>(
|
||||
// check the signature on the statement.
|
||||
match check_statement_signature(&active_head, relay_parent, unchecked_compact) {
|
||||
Err(statement) => {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer,
|
||||
?statement,
|
||||
"Invalid statement signature"
|
||||
);
|
||||
gum::debug!(target: LOG_TARGET, ?peer, ?statement, "Invalid statement signature");
|
||||
report_peer(ctx, peer, COST_INVALID_SIGNATURE).await;
|
||||
return None
|
||||
},
|
||||
@@ -1431,7 +1420,7 @@ async fn handle_incoming_message<'a>(
|
||||
// This fails if the payload doesn't encode correctly.
|
||||
let statement: SignedFullStatement = match checked_compact.convert_to_superpayload(payload) {
|
||||
Err((compact, _)) => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer,
|
||||
?compact,
|
||||
@@ -1453,7 +1442,7 @@ async fn handle_incoming_message<'a>(
|
||||
unreachable!("checked in `check_can_receive` above; qed");
|
||||
},
|
||||
Ok(true) => {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer, ?statement, "Statement accepted");
|
||||
gum::trace!(target: LOG_TARGET, ?peer, ?statement, "Statement accepted");
|
||||
// Send the peer all statements concerning the candidate that we have,
|
||||
// since it appears to have just learned about the candidate.
|
||||
send_statements_about(
|
||||
@@ -1544,7 +1533,7 @@ async fn handle_network_update(
|
||||
) {
|
||||
match update {
|
||||
NetworkBridgeEvent::PeerConnected(peer, role, maybe_authority) => {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer, ?role, "Peer connected");
|
||||
gum::trace!(target: LOG_TARGET, ?peer, ?role, "Peer connected");
|
||||
peers.insert(
|
||||
peer,
|
||||
PeerData {
|
||||
@@ -1560,7 +1549,7 @@ async fn handle_network_update(
|
||||
}
|
||||
},
|
||||
NetworkBridgeEvent::PeerDisconnected(peer) => {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer, "Peer disconnected");
|
||||
gum::trace!(target: LOG_TARGET, ?peer, "Peer disconnected");
|
||||
if let Some(auth_ids) = peers.remove(&peer).and_then(|p| p.maybe_authority) {
|
||||
auth_ids.into_iter().for_each(|a| {
|
||||
authorities.remove(&a);
|
||||
@@ -1600,7 +1589,7 @@ async fn handle_network_update(
|
||||
.await;
|
||||
},
|
||||
NetworkBridgeEvent::PeerViewChange(peer, view) => {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer, ?view, "Peer view change");
|
||||
gum::trace!(target: LOG_TARGET, ?peer, ?view, "Peer view change");
|
||||
match peers.get_mut(&peer) {
|
||||
Some(data) =>
|
||||
update_peer_view_and_maybe_send_unlocked(
|
||||
@@ -1670,7 +1659,7 @@ impl StatementDistributionSubsystem {
|
||||
match result.into_nested()? {
|
||||
Ok(true) => break,
|
||||
Ok(false) => {},
|
||||
Err(jfyi) => tracing::debug!(target: LOG_TARGET, error = ?jfyi),
|
||||
Err(jfyi) => gum::debug!(target: LOG_TARGET, error = ?jfyi),
|
||||
}
|
||||
},
|
||||
MuxedMessage::Requester(result) => {
|
||||
@@ -1820,7 +1809,7 @@ impl StatementDistributionSubsystem {
|
||||
Some(LargeStatementStatus::Fetching(info)) => info,
|
||||
Some(LargeStatementStatus::FetchedOrShared(_)) => {
|
||||
// This task is going to die soon - no need to send it anything.
|
||||
tracing::debug!(target: LOG_TARGET, "Zombie task wanted more peers.");
|
||||
gum::debug!(target: LOG_TARGET, "Zombie task wanted more peers.");
|
||||
return Ok(())
|
||||
},
|
||||
None =>
|
||||
@@ -1867,7 +1856,7 @@ impl StatementDistributionSubsystem {
|
||||
|
||||
for deactivated in deactivated {
|
||||
if active_heads.remove(&deactivated).is_some() {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
hash = ?deactivated,
|
||||
"Deactivating leaf",
|
||||
@@ -1878,7 +1867,7 @@ impl StatementDistributionSubsystem {
|
||||
for activated in activated {
|
||||
let relay_parent = activated.hash;
|
||||
let span = PerLeafSpan::new(activated.span, "statement-distribution");
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
hash = ?relay_parent,
|
||||
"New active leaf",
|
||||
|
||||
@@ -103,7 +103,7 @@ pub async fn fetch(
|
||||
.feed(RequesterMessage::SendRequest(Requests::StatementFetching(outgoing)))
|
||||
.await
|
||||
{
|
||||
tracing::info!(
|
||||
gum::info!(
|
||||
target: LOG_TARGET,
|
||||
?err,
|
||||
"Sending request failed, node might be shutting down - exiting."
|
||||
@@ -122,7 +122,7 @@ pub async fn fetch(
|
||||
if let Err(err) =
|
||||
sender.feed(RequesterMessage::ReportPeer(peer, COST_WRONG_HASH)).await
|
||||
{
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
?err,
|
||||
"Sending reputation change failed: This should not happen."
|
||||
@@ -142,7 +142,7 @@ pub async fn fetch(
|
||||
})
|
||||
.await
|
||||
{
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
?err,
|
||||
"Sending task response failed: This should not happen."
|
||||
@@ -155,7 +155,7 @@ pub async fn fetch(
|
||||
return
|
||||
},
|
||||
Err(err) => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?err,
|
||||
"Receiving response failed with error - trying next peer."
|
||||
@@ -174,7 +174,7 @@ pub async fn fetch(
|
||||
// All our peers failed us - try getting new ones before trying again:
|
||||
match try_get_new_peers(relay_parent, candidate_hash, &mut sender, &span).await {
|
||||
Ok(Some(mut peers)) => {
|
||||
tracing::trace!(target: LOG_TARGET, ?peers, "Received new peers.");
|
||||
gum::trace!(target: LOG_TARGET, ?peers, "Received new peers.");
|
||||
// New arrivals will be tried first:
|
||||
new_peers.append(&mut peers);
|
||||
},
|
||||
@@ -205,7 +205,7 @@ async fn try_get_new_peers(
|
||||
.send(RequesterMessage::GetMorePeers { relay_parent, candidate_hash, tx })
|
||||
.await
|
||||
{
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?err,
|
||||
"Failed sending background task message, subsystem probably moved on."
|
||||
@@ -215,7 +215,7 @@ async fn try_get_new_peers(
|
||||
|
||||
match rx.timeout(RETRY_TIMEOUT).await.transpose() {
|
||||
Err(_) => {
|
||||
tracing::debug!(target: LOG_TARGET, "Failed fetching more peers.");
|
||||
gum::debug!(target: LOG_TARGET, "Failed fetching more peers.");
|
||||
Err(())
|
||||
},
|
||||
Ok(val) => Ok(val),
|
||||
|
||||
@@ -78,11 +78,11 @@ pub async fn respond(
|
||||
let req = match receiver.recv(|| vec![COST_INVALID_REQUEST]).await.into_nested() {
|
||||
Ok(Ok(v)) => v,
|
||||
Err(fatal) => {
|
||||
tracing::debug!(target: LOG_TARGET, error = ?fatal, "Shutting down request responder");
|
||||
gum::debug!(target: LOG_TARGET, error = ?fatal, "Shutting down request responder");
|
||||
return
|
||||
},
|
||||
Ok(Err(jfyi)) => {
|
||||
tracing::debug!(target: LOG_TARGET, error = ?jfyi, "Decoding request failed");
|
||||
gum::debug!(target: LOG_TARGET, error = ?jfyi, "Decoding request failed");
|
||||
continue
|
||||
},
|
||||
};
|
||||
@@ -97,12 +97,12 @@ pub async fn respond(
|
||||
})
|
||||
.await
|
||||
{
|
||||
tracing::debug!(target: LOG_TARGET, ?err, "Shutting down responder");
|
||||
gum::debug!(target: LOG_TARGET, ?err, "Shutting down responder");
|
||||
return
|
||||
}
|
||||
let response = match rx.await {
|
||||
Err(err) => {
|
||||
tracing::debug!(target: LOG_TARGET, ?err, "Requested data not found.");
|
||||
gum::debug!(target: LOG_TARGET, ?err, "Requested data not found.");
|
||||
Err(())
|
||||
},
|
||||
Ok(v) => Ok(StatementFetchingResponse::Statement(v)),
|
||||
@@ -115,7 +115,7 @@ pub async fn respond(
|
||||
};
|
||||
pending_out.push(pending_sent_rx);
|
||||
if let Err(_) = req.send_outgoing_response(response) {
|
||||
tracing::debug!(target: LOG_TARGET, "Sending response failed");
|
||||
gum::debug!(target: LOG_TARGET, "Sending response failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,7 +1275,7 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing(
|
||||
),
|
||||
)
|
||||
) => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?recipients,
|
||||
"Recipients received"
|
||||
@@ -1613,7 +1613,7 @@ fn share_prioritizes_backing_group() {
|
||||
),
|
||||
)
|
||||
) => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?recipients,
|
||||
"Recipients received"
|
||||
|
||||
Reference in New Issue
Block a user