Skip to content

Commit

Permalink
tracing for logging in fatxpool
Browse files Browse the repository at this point in the history
  • Loading branch information
dharjeezy committed Dec 14, 2024
1 parent ec69b61 commit fda202e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
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.

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-tracing = { workspace = true, default-features = true }
sp-transaction-pool = { workspace = true, default-features = true }
tokio-stream = { workspace = true }
tokio = { workspace = true, default-features = true, features = ["macros", "time"] }
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 @@ -22,6 +22,7 @@ pub(crate) mod api;
pub(crate) mod enactment_state;
pub(crate) mod error;
pub(crate) mod log_xt;
pub(crate) mod tracing_log_xt;
pub(crate) mod metrics;
#[cfg(test)]
pub(crate) mod tests;
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,13 @@
//! 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 tracing::{debug, trace};
use sc_transaction_pool_api::TransactionStatus;
use sc_utils::mpsc;
use sp_runtime::traits::Block as BlockT;
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" );
return Some(DroppedTransaction::new_enforced_by_limts(tx_hash))
}
},
Expand Down

0 comments on commit fda202e

Please sign in to comment.