Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing for logging in fatxpool #6897

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions prdoc/pr_6897.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: 'Tracing Log for fork-aware transaction pool'
doc:
- audience: Node Dev
description: Replacement of log crate with tracing crate for better logging.
crates:
- name: sc-transaction-pool
bump: minor
1 change: 1 addition & 0 deletions substrate/client/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ sp-transaction-pool = { workspace = true, default-features = true }
thiserror = { workspace = true }
tokio = { workspace = true, default-features = true, features = ["macros", "time"] }
tokio-stream = { workspace = true }
tracing = { workspace = true, default-features = true }

[dev-dependencies]
array-bytes = { workspace = true, default-features = true }
Expand Down
1 change: 1 addition & 0 deletions substrate/client/transaction-pool/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub(crate) mod log_xt;
pub(crate) mod metrics;
#[cfg(test)]
pub(crate) mod tests;
pub(crate) mod tracing_log_xt;

use futures::StreamExt;
use std::sync::Arc;
Expand Down
48 changes: 48 additions & 0 deletions substrate/client/transaction-pool/src/common/tracing_log_xt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
macro_rules! log_xt {
(data: hash, target: $target:expr, $level:expr, $tx_collection:expr, $text_with_format:expr) => {
for tx in $tx_collection {
tracing::event!(
$level,
target = $target,
message = $text_with_format,
tx = format!("{:?}", tx)
);
}
};
(data: hash, target: $target:expr, $level:expr, $tx_collection:expr, $text_with_format:expr, $($arg:expr),*) => {
for tx in $tx_collection {
tracing::event!(
$level,
target = $target,
message = $text_with_format,
tx = format!("{:?}", tx),
$($arg),*
);
}
};
(data: tuple, target: $target:expr, $level:expr, $tx_collection:expr, $text_with_format:expr) => {
for tx in $tx_collection {
tracing::event!(
$level,
target = $target,
message = $text_with_format,
tx_0 = format!("{:?}", tx.0),
tx_1 = format!("{:?}", tx.1)
);
}
};
}
macro_rules! log_xt_trace {
(data: $datatype:ident, target: $target:expr, $($arg:tt)+) => {
$crate::common::tracing_log_xt::log_xt!(data: $datatype, target: $target, tracing::Level::TRACE, $($arg)+);
};
(target: $target:expr, $tx_collection:expr, $text_with_format:expr) => {
$crate::common::tracing_log_xt::log_xt!(data: hash, target: $target, tracing::Level::TRACE, $tx_collection, $text_with_format);
};
(target: $target:expr, $tx_collection:expr, $text_with_format:expr, $($arg:expr)*) => {
$crate::common::tracing_log_xt::log_xt!(data: hash, target: $target, tracing::Level::TRACE, $tx_collection, $text_with_format, $($arg)*);
};
}

pub(crate) use log_xt;
pub(crate) use log_xt_trace;
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
//! by any view are detected and properly notified.

use crate::{
common::log_xt::log_xt_trace,
common::tracing_log_xt::log_xt_trace,
fork_aware_txpool::stream_map_util::next_event,
graph::{self, BlockHash, ExtrinsicHash},
LOG_TARGET,
};
use futures::stream::StreamExt;
use log::{debug, trace};
use sc_transaction_pool_api::TransactionStatus;
use sc_utils::mpsc;
use sp_runtime::traits::Block as BlockT;
Expand All @@ -41,6 +40,7 @@ use std::{
pin::Pin,
};
use tokio_stream::StreamMap;
use tracing::{debug, trace};

/// Represents a transaction that was removed from the transaction pool, including the reason of its
/// removal.
Expand Down Expand Up @@ -275,7 +275,8 @@ where
return Some(DroppedTransaction::new_enforced_by_limts(tx_hash))
}
} else {
debug!("[{:?}] dropped_watcher: removing (non-tracked) tx", tx_hash);
let tx_hash_string = format!("{:?}", tx_hash);
debug!(tx_hash_string, "dropped_watcher: removing (non-tracked) tx");
Comment on lines +278 to +279
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let tx_hash_string = format!("{:?}", tx_hash);
debug!(tx_hash_string, "dropped_watcher: removing (non-tracked) tx");
debug!(target: LOG_TARGET, ?tx_hash, "dropped_watcher: removing (non-tracked) tx");

return Some(DroppedTransaction::new_enforced_by_limts(tx_hash))
}
},
Expand Down
Loading
Loading