Skip to content

Commit

Permalink
Merge pull request #3147 from eqlabs/feat/tps_metrics
Browse files Browse the repository at this point in the history
feat: more TPS metrics
  • Loading branch information
howardwu committed Mar 5, 2024
2 parents 8be6ac9 + 8c3bfba commit 6aba25d
Show file tree
Hide file tree
Showing 3 changed files with 527 additions and 30 deletions.
17 changes: 16 additions & 1 deletion node/consensus/src/lib.rs
Expand Up @@ -212,6 +212,11 @@ impl<N: Network> Consensus<N> {
impl<N: Network> Consensus<N> {
/// Adds the given unconfirmed solution to the memory pool.
pub async fn add_unconfirmed_solution(&self, solution: ProverSolution<N>) -> Result<()> {
#[cfg(feature = "metrics")]
{
metrics::increment_gauge(metrics::consensus::UNCONFIRMED_SOLUTIONS, 1f64);
metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64);
}
// Process the unconfirmed solution.
{
let solution_id = solution.commitment();
Expand Down Expand Up @@ -265,6 +270,11 @@ impl<N: Network> Consensus<N> {

/// Adds the given unconfirmed transaction to the memory pool.
pub async fn add_unconfirmed_transaction(&self, transaction: Transaction<N>) -> Result<()> {
#[cfg(feature = "metrics")]
{
metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSACTIONS, 1f64);
metrics::increment_gauge(metrics::consensus::UNCONFIRMED_TRANSMISSIONS, 1f64);
}
// Process the unconfirmed transaction.
{
let transaction_id = transaction.id();
Expand Down Expand Up @@ -405,9 +415,14 @@ impl<N: Network> Consensus<N> {
let elapsed = std::time::Duration::from_secs((snarkos_node_bft::helpers::now() - start) as u64);
let next_block_timestamp = next_block.header().metadata().timestamp();
let block_latency = next_block_timestamp - current_block_timestamp;
let num_sol = next_block.solutions().len();
let num_tx = next_block.transactions().len();
let num_transmissions = num_tx + num_sol;

metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64);
metrics::increment_gauge(metrics::blocks::TRANSACTIONS, next_block.transactions().len() as f64);
metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64);
metrics::increment_gauge(metrics::blocks::TRANSACTIONS, num_tx as f64);
metrics::increment_gauge(metrics::blocks::TRANSMISSIONS, num_transmissions as f64);
metrics::gauge(metrics::consensus::LAST_COMMITTED_ROUND, next_block.round() as f64);
metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64);
metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64());
Expand Down

0 comments on commit 6aba25d

Please sign in to comment.