mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17: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
@@ -206,11 +206,11 @@ impl State {
|
||||
match event {
|
||||
NetworkBridgeEvent::PeerConnected(peer_id, role, _) => {
|
||||
// insert a blank view if none already present
|
||||
tracing::trace!(target: LOG_TARGET, ?peer_id, ?role, "Peer connected");
|
||||
gum::trace!(target: LOG_TARGET, ?peer_id, ?role, "Peer connected");
|
||||
self.peer_views.entry(peer_id).or_default();
|
||||
},
|
||||
NetworkBridgeEvent::PeerDisconnected(peer_id) => {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer_id, "Peer disconnected");
|
||||
gum::trace!(target: LOG_TARGET, ?peer_id, "Peer disconnected");
|
||||
self.peer_views.remove(&peer_id);
|
||||
self.blocks.iter_mut().for_each(|(_hash, entry)| {
|
||||
entry.known_by.remove(&peer_id);
|
||||
@@ -230,7 +230,7 @@ impl State {
|
||||
self.handle_peer_view_change(ctx, metrics, peer_id, view).await;
|
||||
},
|
||||
NetworkBridgeEvent::OurViewChange(view) => {
|
||||
tracing::trace!(target: LOG_TARGET, ?view, "Own view change");
|
||||
gum::trace!(target: LOG_TARGET, ?view, "Own view change");
|
||||
for head in view.iter() {
|
||||
if !self.blocks.contains_key(head) {
|
||||
self.pending_known.entry(*head).or_default();
|
||||
@@ -240,7 +240,7 @@ impl State {
|
||||
self.pending_known.retain(|h, _| {
|
||||
let live = view.contains(h);
|
||||
if !live {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
block_hash = ?h,
|
||||
"Cleaning up stale pending messages",
|
||||
@@ -287,7 +287,7 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Got new blocks {:?}",
|
||||
metas.iter().map(|m| (m.hash, m.number)).collect::<Vec<_>>(),
|
||||
@@ -318,7 +318,7 @@ impl State {
|
||||
let to_import = pending_now_known
|
||||
.into_iter()
|
||||
.inspect(|h| {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
block_hash = ?h,
|
||||
"Extracting pending messages for new block"
|
||||
@@ -329,7 +329,7 @@ impl State {
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !to_import.is_empty() {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
num = to_import.len(),
|
||||
"Processing pending assignment/approvals",
|
||||
@@ -374,7 +374,7 @@ impl State {
|
||||
) {
|
||||
match msg {
|
||||
protocol_v1::ApprovalDistributionMessage::Assignments(assignments) => {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = %peer_id,
|
||||
num = assignments.len(),
|
||||
@@ -388,7 +388,7 @@ impl State {
|
||||
assignment.validator,
|
||||
);
|
||||
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
%peer_id,
|
||||
?fingerprint,
|
||||
@@ -414,7 +414,7 @@ impl State {
|
||||
}
|
||||
},
|
||||
protocol_v1::ApprovalDistributionMessage::Approvals(approvals) => {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = %peer_id,
|
||||
num = approvals.len(),
|
||||
@@ -428,7 +428,7 @@ impl State {
|
||||
approval_vote.validator,
|
||||
);
|
||||
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
%peer_id,
|
||||
?fingerprint,
|
||||
@@ -460,7 +460,7 @@ impl State {
|
||||
peer_id: PeerId,
|
||||
view: View,
|
||||
) {
|
||||
tracing::trace!(target: LOG_TARGET, ?view, "Peer view change");
|
||||
gum::trace!(target: LOG_TARGET, ?view, "Peer view change");
|
||||
let finalized_number = view.finalized_number;
|
||||
let old_view = self.peer_views.insert(peer_id.clone(), view.clone());
|
||||
let old_finalized_number = old_view.map(|v| v.finalized_number).unwrap_or(0);
|
||||
@@ -525,7 +525,7 @@ impl State {
|
||||
Some(entry) => entry,
|
||||
None => {
|
||||
if let Some(peer_id) = source.peer_id() {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
?block_hash,
|
||||
@@ -549,7 +549,7 @@ impl State {
|
||||
let peer_knowledge = peer_knowledge.get_mut();
|
||||
if peer_knowledge.contains(&fingerprint) {
|
||||
if peer_knowledge.received.contains(&fingerprint) {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
?fingerprint,
|
||||
@@ -562,7 +562,7 @@ impl State {
|
||||
}
|
||||
},
|
||||
hash_map::Entry::Vacant(_) => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
?fingerprint,
|
||||
@@ -576,7 +576,7 @@ impl State {
|
||||
if entry.knowledge.known_messages.contains(&fingerprint) {
|
||||
modify_reputation(ctx, peer_id.clone(), BENEFIT_VALID_MESSAGE).await;
|
||||
if let Some(peer_knowledge) = entry.known_by.get_mut(&peer_id) {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer_id, ?fingerprint, "Known assignment");
|
||||
gum::trace!(target: LOG_TARGET, ?peer_id, ?fingerprint, "Known assignment");
|
||||
peer_knowledge.received.insert(fingerprint.clone());
|
||||
}
|
||||
return
|
||||
@@ -595,19 +595,13 @@ impl State {
|
||||
let result = match rx.await {
|
||||
Ok(result) => result,
|
||||
Err(_) => {
|
||||
tracing::debug!(target: LOG_TARGET, "The approval voting subsystem is down");
|
||||
gum::debug!(target: LOG_TARGET, "The approval voting subsystem is down");
|
||||
return
|
||||
},
|
||||
};
|
||||
drop(timer);
|
||||
|
||||
tracing::trace!(
|
||||
target: LOG_TARGET,
|
||||
?source,
|
||||
?fingerprint,
|
||||
?result,
|
||||
"Checked assignment",
|
||||
);
|
||||
gum::trace!(target: LOG_TARGET, ?source, ?fingerprint, ?result, "Checked assignment",);
|
||||
match result {
|
||||
AssignmentCheckResult::Accepted => {
|
||||
modify_reputation(ctx, peer_id.clone(), BENEFIT_VALID_MESSAGE_FIRST).await;
|
||||
@@ -623,7 +617,7 @@ impl State {
|
||||
if let Some(peer_knowledge) = entry.known_by.get_mut(&peer_id) {
|
||||
peer_knowledge.received.insert(fingerprint);
|
||||
}
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
"Got an `AcceptedDuplicate` assignment",
|
||||
@@ -631,7 +625,7 @@ impl State {
|
||||
return
|
||||
},
|
||||
AssignmentCheckResult::TooFarInFuture => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
"Got an assignment too far in the future",
|
||||
@@ -640,7 +634,7 @@ impl State {
|
||||
return
|
||||
},
|
||||
AssignmentCheckResult::Bad(error) => {
|
||||
tracing::info!(
|
||||
gum::info!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
%error,
|
||||
@@ -653,18 +647,14 @@ impl State {
|
||||
} else {
|
||||
if !entry.knowledge.known_messages.insert(fingerprint.clone()) {
|
||||
// if we already imported an assignment, there is no need to distribute it again
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
?fingerprint,
|
||||
"Importing locally an already known assignment",
|
||||
);
|
||||
return
|
||||
} else {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
?fingerprint,
|
||||
"Importing locally a new assignment",
|
||||
);
|
||||
gum::debug!(target: LOG_TARGET, ?fingerprint, "Importing locally a new assignment",);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,7 +672,7 @@ impl State {
|
||||
});
|
||||
},
|
||||
None => {
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
hash = ?block_hash,
|
||||
?claimed_candidate_index,
|
||||
@@ -716,7 +706,7 @@ impl State {
|
||||
}
|
||||
|
||||
if !peers.is_empty() {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?block_hash,
|
||||
?claimed_candidate_index,
|
||||
@@ -769,7 +759,7 @@ impl State {
|
||||
);
|
||||
|
||||
if !entry.knowledge.known_messages.contains(&assignment_fingerprint) {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
?fingerprint,
|
||||
@@ -785,7 +775,7 @@ impl State {
|
||||
let peer_knowledge = knowledge.get_mut();
|
||||
if peer_knowledge.contains(&fingerprint) {
|
||||
if peer_knowledge.received.contains(&fingerprint) {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
?fingerprint,
|
||||
@@ -799,7 +789,7 @@ impl State {
|
||||
}
|
||||
},
|
||||
hash_map::Entry::Vacant(_) => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
?fingerprint,
|
||||
@@ -811,7 +801,7 @@ impl State {
|
||||
|
||||
// if the approval is known to be valid, reward the peer
|
||||
if entry.knowledge.contains(&fingerprint) {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer_id, ?fingerprint, "Known approval");
|
||||
gum::trace!(target: LOG_TARGET, ?peer_id, ?fingerprint, "Known approval");
|
||||
modify_reputation(ctx, peer_id.clone(), BENEFIT_VALID_MESSAGE).await;
|
||||
if let Some(peer_knowledge) = entry.known_by.get_mut(&peer_id) {
|
||||
peer_knowledge.received.insert(fingerprint.clone());
|
||||
@@ -828,19 +818,13 @@ impl State {
|
||||
let result = match rx.await {
|
||||
Ok(result) => result,
|
||||
Err(_) => {
|
||||
tracing::debug!(target: LOG_TARGET, "The approval voting subsystem is down");
|
||||
gum::debug!(target: LOG_TARGET, "The approval voting subsystem is down");
|
||||
return
|
||||
},
|
||||
};
|
||||
drop(timer);
|
||||
|
||||
tracing::trace!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
?fingerprint,
|
||||
?result,
|
||||
"Checked approval",
|
||||
);
|
||||
gum::trace!(target: LOG_TARGET, ?peer_id, ?fingerprint, ?result, "Checked approval",);
|
||||
match result {
|
||||
ApprovalCheckResult::Accepted => {
|
||||
modify_reputation(ctx, peer_id.clone(), BENEFIT_VALID_MESSAGE_FIRST).await;
|
||||
@@ -852,7 +836,7 @@ impl State {
|
||||
},
|
||||
ApprovalCheckResult::Bad(error) => {
|
||||
modify_reputation(ctx, peer_id, COST_INVALID_MESSAGE).await;
|
||||
tracing::info!(
|
||||
gum::info!(
|
||||
target: LOG_TARGET,
|
||||
?peer_id,
|
||||
%error,
|
||||
@@ -864,18 +848,14 @@ impl State {
|
||||
} else {
|
||||
if !entry.knowledge.insert(fingerprint.clone()) {
|
||||
// if we already imported an approval, there is no need to distribute it again
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
?fingerprint,
|
||||
"Importing locally an already known approval",
|
||||
);
|
||||
return
|
||||
} else {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
?fingerprint,
|
||||
"Importing locally a new approval",
|
||||
);
|
||||
gum::debug!(target: LOG_TARGET, ?fingerprint, "Importing locally a new approval",);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,7 +882,7 @@ impl State {
|
||||
},
|
||||
None => {
|
||||
// this would indicate a bug in approval-voting
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
hash = ?block_hash,
|
||||
?candidate_index,
|
||||
@@ -913,7 +893,7 @@ impl State {
|
||||
}
|
||||
},
|
||||
None => {
|
||||
tracing::warn!(
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
hash = ?block_hash,
|
||||
?candidate_index,
|
||||
@@ -948,7 +928,7 @@ impl State {
|
||||
|
||||
let approvals = vec![vote];
|
||||
if !peers.is_empty() {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?block_hash,
|
||||
?candidate_index,
|
||||
@@ -1004,7 +984,7 @@ impl State {
|
||||
// This safeguard is needed primarily in case of long finality stalls
|
||||
// so we don't waste time in a loop for every peer.
|
||||
if missing.is_empty() {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?block,
|
||||
?peer_id,
|
||||
@@ -1036,7 +1016,7 @@ impl State {
|
||||
util::MIN_GOSSIP_PEERS,
|
||||
);
|
||||
if !lucky {
|
||||
tracing::trace!(target: LOG_TARGET, ?peer_id, "Unlucky peer");
|
||||
gum::trace!(target: LOG_TARGET, ?peer_id, "Unlucky peer");
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1062,7 +1042,7 @@ impl State {
|
||||
None => continue, // should be unreachable
|
||||
};
|
||||
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
"Sending all assignments and approvals in block {} to peer {}",
|
||||
block,
|
||||
@@ -1083,7 +1063,7 @@ impl State {
|
||||
match approval_state {
|
||||
ApprovalState::Assigned(cert) => {
|
||||
if !missing.contains(&assignment_fingerprint) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?block,
|
||||
?validator_index,
|
||||
@@ -1123,7 +1103,7 @@ impl State {
|
||||
candidate_index.clone(),
|
||||
));
|
||||
} else {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?block,
|
||||
?validator_index,
|
||||
@@ -1142,7 +1122,7 @@ impl State {
|
||||
signature: signature.clone(),
|
||||
});
|
||||
} else {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?block,
|
||||
?validator_index,
|
||||
@@ -1157,7 +1137,7 @@ impl State {
|
||||
}
|
||||
|
||||
if !assignments.is_empty() {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
num = assignments.len(),
|
||||
?num_blocks,
|
||||
@@ -1175,7 +1155,7 @@ impl State {
|
||||
}
|
||||
|
||||
if !approvals.is_empty() {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
num = approvals.len(),
|
||||
?num_blocks,
|
||||
@@ -1201,7 +1181,7 @@ async fn modify_reputation(
|
||||
peer_id: PeerId,
|
||||
rep: Rep,
|
||||
) {
|
||||
tracing::trace!(
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
reputation = ?rep,
|
||||
?peer_id,
|
||||
@@ -1236,7 +1216,7 @@ impl ApprovalDistribution {
|
||||
let message = match ctx.recv().await {
|
||||
Ok(message) => message,
|
||||
Err(e) => {
|
||||
tracing::debug!(target: LOG_TARGET, err = ?e, "Failed to receive a message from Overseer, exiting");
|
||||
gum::debug!(target: LOG_TARGET, err = ?e, "Failed to receive a message from Overseer, exiting");
|
||||
return
|
||||
},
|
||||
};
|
||||
@@ -1249,13 +1229,13 @@ impl ApprovalDistribution {
|
||||
FromOverseer::Communication {
|
||||
msg: ApprovalDistributionMessage::NewBlocks(metas),
|
||||
} => {
|
||||
tracing::debug!(target: LOG_TARGET, "Processing NewBlocks");
|
||||
gum::debug!(target: LOG_TARGET, "Processing NewBlocks");
|
||||
state.handle_new_blocks(&mut ctx, &self.metrics, metas).await;
|
||||
},
|
||||
FromOverseer::Communication {
|
||||
msg: ApprovalDistributionMessage::DistributeAssignment(cert, candidate_index),
|
||||
} => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Distributing our assignment on candidate (block={}, index={})",
|
||||
cert.block_hash,
|
||||
@@ -1275,7 +1255,7 @@ impl ApprovalDistribution {
|
||||
FromOverseer::Communication {
|
||||
msg: ApprovalDistributionMessage::DistributeApproval(vote),
|
||||
} => {
|
||||
tracing::debug!(
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Distributing our approval vote on candidate (block={}, index={})",
|
||||
vote.block_hash,
|
||||
@@ -1294,11 +1274,11 @@ impl ApprovalDistribution {
|
||||
FromOverseer::Signal(OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
|
||||
..
|
||||
})) => {
|
||||
tracing::trace!(target: LOG_TARGET, "active leaves signal (ignored)");
|
||||
gum::trace!(target: LOG_TARGET, "active leaves signal (ignored)");
|
||||
// handled by NewBlocks
|
||||
},
|
||||
FromOverseer::Signal(OverseerSignal::BlockFinalized(_hash, number)) => {
|
||||
tracing::trace!(target: LOG_TARGET, number = %number, "finalized signal");
|
||||
gum::trace!(target: LOG_TARGET, number = %number, "finalized signal");
|
||||
state.handle_block_finalized(number);
|
||||
},
|
||||
FromOverseer::Signal(OverseerSignal::Conclude) => return,
|
||||
|
||||
@@ -72,7 +72,7 @@ fn test_harness<T: Future<Output = VirtualOverseer>>(
|
||||
const TIMEOUT: Duration = Duration::from_millis(100);
|
||||
|
||||
async fn overseer_send(overseer: &mut VirtualOverseer, msg: ApprovalDistributionMessage) {
|
||||
tracing::trace!(msg = ?msg, "Sending message");
|
||||
gum::trace!(msg = ?msg, "Sending message");
|
||||
overseer
|
||||
.send(FromOverseer::Communication { msg })
|
||||
.timeout(TIMEOUT)
|
||||
@@ -81,7 +81,7 @@ async fn overseer_send(overseer: &mut VirtualOverseer, msg: ApprovalDistribution
|
||||
}
|
||||
|
||||
async fn overseer_signal_block_finalized(overseer: &mut VirtualOverseer, number: BlockNumber) {
|
||||
tracing::trace!(?number, "Sending a finalized signal");
|
||||
gum::trace!(?number, "Sending a finalized signal");
|
||||
// we don't care about the block hash
|
||||
overseer
|
||||
.send(FromOverseer::Signal(OverseerSignal::BlockFinalized(Hash::zero(), number)))
|
||||
@@ -91,10 +91,10 @@ async fn overseer_signal_block_finalized(overseer: &mut VirtualOverseer, number:
|
||||
}
|
||||
|
||||
async fn overseer_recv(overseer: &mut VirtualOverseer) -> AllMessages {
|
||||
tracing::trace!("Waiting for a message");
|
||||
gum::trace!("Waiting for a message");
|
||||
let msg = overseer.recv().timeout(TIMEOUT).await.expect("msg recv timeout");
|
||||
|
||||
tracing::trace!(msg = ?msg, "Received message");
|
||||
gum::trace!(msg = ?msg, "Received message");
|
||||
|
||||
msg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user