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:
Bernhard Schuster
2022-03-15 12:05:16 +01:00
committed by GitHub
parent fa359fd1f7
commit d631f1dea8
130 changed files with 1708 additions and 808 deletions
+41 -43
View File
@@ -621,7 +621,7 @@ impl State {
let session_info = match self.session_info(block_entry.session()) {
Some(s) => s,
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Unknown session info for {}",
block_entry.session()
@@ -718,7 +718,7 @@ where
match rx.await? {
Ok(number) => Some(number),
Err(err) => {
tracing::warn!(target: LOG_TARGET, ?err, "Failed fetching finalized number");
gum::warn!(target: LOG_TARGET, ?err, "Failed fetching finalized number");
None
},
}
@@ -962,13 +962,11 @@ async fn handle_actions(
match confirmation_rx.await {
Err(oneshot::Canceled) => {
tracing::debug!(target: LOG_TARGET, "Dispute coordinator confirmation lost",)
gum::debug!(target: LOG_TARGET, "Dispute coordinator confirmation lost",)
},
Ok(ImportStatementsResult::ValidImport) => {},
Ok(ImportStatementsResult::InvalidImport) => tracing::warn!(
target: LOG_TARGET,
"Failed to import statements of validity",
),
Ok(ImportStatementsResult::InvalidImport) =>
gum::warn!(target: LOG_TARGET, "Failed to import statements of validity",),
}
},
Action::NoteApprovedInChainSelection(block_hash) => {
@@ -1004,7 +1002,7 @@ fn distribution_messages_for_activation(
let block_entry = match db.load_block_entry(&block_hash)? {
Some(b) => b,
None => {
tracing::warn!(target: LOG_TARGET, ?block_hash, "Missing block entry");
gum::warn!(target: LOG_TARGET, ?block_hash, "Missing block entry");
continue
},
@@ -1021,7 +1019,7 @@ fn distribution_messages_for_activation(
let candidate_entry = match db.load_candidate_entry(&candidate_hash)? {
Some(c) => c,
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?block_hash,
?candidate_hash,
@@ -1068,7 +1066,7 @@ fn distribution_messages_for_activation(
}
},
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?block_hash,
?candidate_hash,
@@ -1105,7 +1103,7 @@ async fn handle_from_overseer(
Ok(block_imported_candidates) => {
// Schedule wakeups for all imported candidates.
for block_batch in block_imported_candidates {
tracing::debug!(
gum::debug!(
target: LOG_TARGET,
block_number = ?block_batch.block_number,
block_hash = ?block_batch.block_hash,
@@ -1122,7 +1120,7 @@ async fn handle_from_overseer(
if let Some(our_tranche) = our_tranche {
let tick = our_tranche as Tick + block_batch.block_tick;
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
tranche = our_tranche,
candidate_hash = ?c_hash,
@@ -1150,7 +1148,7 @@ async fn handle_from_overseer(
actions
},
FromOverseer::Signal(OverseerSignal::BlockFinalized(block_hash, block_number)) => {
tracing::debug!(target: LOG_TARGET, ?block_hash, ?block_number, "Block finalized");
gum::debug!(target: LOG_TARGET, ?block_hash, ?block_number, "Block finalized");
*last_finalized_height = Some(block_number);
crate::ops::canonicalize(db, block_number, block_hash)
@@ -1262,7 +1260,7 @@ async fn handle_approved_ancestor(
let entry = match db.load_block_entry(&block_hash)? {
None => {
let block_number = target_number.saturating_sub(i as u32);
tracing::info!(
gum::info!(
target: LOG_TARGET,
unknown_number = ?block_number,
unknown_hash = ?block_hash,
@@ -1303,7 +1301,7 @@ async fn handle_approved_ancestor(
block_descriptions.clear();
let unapproved: Vec<_> = entry.unapproved_candidates().collect();
tracing::debug!(
gum::debug!(
target: LOG_TARGET,
"Block {} is {} blocks deep and has {}/{} candidates unapproved",
block_hash,
@@ -1315,7 +1313,7 @@ async fn handle_approved_ancestor(
for candidate_hash in unapproved {
match db.load_candidate_entry(&candidate_hash)? {
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?candidate_hash,
"Missing expected candidate in DB",
@@ -1325,7 +1323,7 @@ async fn handle_approved_ancestor(
},
Some(c_entry) => match c_entry.approval_entry(&block_hash) {
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
@@ -1357,7 +1355,7 @@ async fn handle_approved_ancestor(
};
match a_entry.our_assignment() {
None => tracing::debug!(
None => gum::debug!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
@@ -1374,7 +1372,7 @@ async fn handle_approved_ancestor(
let approved =
triggered && { a_entry.local_statements().1.is_some() };
tracing::debug!(
gum::debug!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
@@ -1394,7 +1392,7 @@ async fn handle_approved_ancestor(
}
}
tracing::debug!(
gum::debug!(
target: LOG_TARGET,
"approved blocks {}-[{}]-{}",
target_number,
@@ -1507,7 +1505,7 @@ fn schedule_wakeup_action(
};
match maybe_action {
Some(Action::ScheduleWakeup { ref tick, .. }) => tracing::trace!(
Some(Action::ScheduleWakeup { ref tick, .. }) => gum::trace!(
target: LOG_TARGET,
tick,
?candidate_hash,
@@ -1515,7 +1513,7 @@ fn schedule_wakeup_action(
block_tick,
"Scheduling next wakeup.",
),
None => tracing::trace!(
None => gum::trace!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
@@ -1633,7 +1631,7 @@ fn check_and_import_assignment(
if is_duplicate {
AssignmentCheckResult::AcceptedDuplicate
} else {
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
validator = assignment.validator.0,
candidate_hash = ?assigned_candidate_hash,
@@ -1756,7 +1754,7 @@ fn check_and_import_approval<T>(
// importing the approval can be heavy as it may trigger acceptance for a series of blocks.
let t = with_response(ApprovalCheckResult::Accepted);
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
validator_index = approval.validator.0,
validator = ?pubkey,
@@ -1877,7 +1875,7 @@ fn advance_approval_state(
let is_approved = check.is_approved(tick_now.saturating_sub(APPROVAL_DELAY));
if is_approved {
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
@@ -1906,7 +1904,7 @@ fn advance_approval_state(
(is_approved, status)
} else {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
@@ -2021,7 +2019,7 @@ fn process_wakeup(
let session_info = match state.session_info(block_entry.session()) {
Some(i) => i,
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Missing session info for live block {} in session {}",
relay_block,
@@ -2040,7 +2038,7 @@ fn process_wakeup(
let tranche_now = state.clock.tranche_now(state.slot_duration_millis, block_entry.slot());
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
tranche = tranche_now,
?candidate_hash,
@@ -2100,7 +2098,7 @@ fn process_wakeup(
block_entry.candidates().iter().position(|(_, h)| &candidate_hash == h);
if let Some(i) = index_in_candidate {
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
?candidate_hash,
para_id = ?candidate_receipt.descriptor.para_id,
@@ -2185,7 +2183,7 @@ async fn launch_approval(
let candidate_hash = candidate.hash();
let para_id = candidate.descriptor.para_id;
tracing::trace!(target: LOG_TARGET, ?candidate_hash, ?para_id, "Recovering data.");
gum::trace!(target: LOG_TARGET, ?candidate_hash, ?para_id, "Recovering data.");
let timer = metrics.time_recover_and_approve();
ctx.send_message(AvailabilityRecoveryMessage::RecoverAvailableData(
@@ -2219,7 +2217,7 @@ async fn launch_approval(
Ok(Err(e)) => {
match &e {
&RecoveryError::Unavailable => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?para_id,
?candidate_hash,
@@ -2230,7 +2228,7 @@ async fn launch_approval(
metrics_guard.take().on_approval_unavailable();
},
&RecoveryError::Invalid => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?para_id,
?candidate_hash,
@@ -2261,7 +2259,7 @@ async fn launch_approval(
Ok(Err(_)) => return ApprovalState::failed(validator_index, candidate_hash),
Ok(Ok(Some(code))) => code,
Ok(Ok(None)) => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Validation code unavailable for block {:?} in the state of block {:?} (a recent descendant)",
candidate.descriptor.relay_parent,
@@ -2297,7 +2295,7 @@ async fn launch_approval(
// Validation checked out. Issue an approval command. If the underlying service is unreachable,
// then there isn't anything we can do.
tracing::trace!(target: LOG_TARGET, ?candidate_hash, ?para_id, "Candidate Valid");
gum::trace!(target: LOG_TARGET, ?candidate_hash, ?para_id, "Candidate Valid");
let expected_commitments_hash = candidate.commitments_hash;
if commitments.hash() == expected_commitments_hash {
@@ -2322,7 +2320,7 @@ async fn launch_approval(
}
},
Ok(Ok(ValidationResult::Invalid(reason))) => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
?reason,
?candidate_hash,
@@ -2346,7 +2344,7 @@ async fn launch_approval(
return ApprovalState::failed(validator_index, candidate_hash)
},
Ok(Err(e)) => {
tracing::error!(
gum::error!(
target: LOG_TARGET,
err = ?e,
?candidate_hash,
@@ -2385,7 +2383,7 @@ async fn issue_approval(
let candidate_index = match block_entry.candidates().iter().position(|e| e.1 == candidate_hash)
{
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Candidate hash {} is not present in the block entry's candidates for relay block {}",
candidate_hash,
@@ -2401,7 +2399,7 @@ async fn issue_approval(
let session_info = match state.session_info(block_entry.session()) {
Some(s) => s,
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Missing session info for live block {} in session {}",
block_hash,
@@ -2416,7 +2414,7 @@ async fn issue_approval(
let candidate_hash = match block_entry.candidate(candidate_index as usize) {
Some((_, h)) => h.clone(),
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Received malformed request to approve out-of-bounds candidate index {} included at block {:?}",
candidate_index,
@@ -2431,7 +2429,7 @@ async fn issue_approval(
let candidate_entry = match db.load_candidate_entry(&candidate_hash)? {
Some(c) => c,
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Missing entry for candidate index {} included at block {:?}",
candidate_index,
@@ -2446,7 +2444,7 @@ async fn issue_approval(
let validator_pubkey = match session_info.validators.get(validator_index.0 as usize) {
Some(p) => p,
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
"Validator index {} out of bounds in session {}",
validator_index.0,
@@ -2462,7 +2460,7 @@ async fn issue_approval(
let sig = match sign_approval(&state.keystore, &validator_pubkey, candidate_hash, session) {
Some(sig) => sig,
None => {
tracing::warn!(
gum::warn!(
target: LOG_TARGET,
validator_index = ?validator_index,
session,
@@ -2485,7 +2483,7 @@ async fn issue_approval(
)
.expect("Statement just signed; should pass checks; qed");
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,