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

fatxpool: use tracing for logging #6897

Merged
Merged
Show file tree
Hide file tree
Changes from 10 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 }
iulianbarbu marked this conversation as resolved.
Show resolved Hide resolved

[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 {
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
(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_hash = format!("{:?}", tx)
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
);
}
};
(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_hash = format!("{:?}", tx),
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
$($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_hash = format!("{:?}", tx.0),
some_value = format!("{:?}", tx.1)
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
);
}
};
}
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 @@ -279,7 +279,7 @@ where
return Some(DroppedTransaction::new_enforced_by_limts(tx_hash))
}
} else {
debug!("[{:?}] dropped_watcher: removing (non-tracked) tx", tx_hash);
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