Skip to content

Commit

Permalink
[consensus] Counter for consensus messages by type (MystenLabs#8759)
Browse files Browse the repository at this point in the history
  • Loading branch information
andll authored Mar 1, 2023
1 parent fa726b4 commit 91b6e22
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ pub struct AuthorityMetrics {
/// Consensus handler metrics
pub consensus_handler_processed_batches: IntCounter,
pub consensus_handler_processed_bytes: IntCounter,
pub consensus_handler_processed: IntCounterVec,
}

// Override default Prom buckets for positive numbers in 0-50k range
Expand Down Expand Up @@ -383,6 +384,8 @@ impl AuthorityMetrics {
"Number of bytes processed by consensus_handler",
registry
).unwrap(),
consensus_handler_processed: register_int_counter_vec_with_registry!("consensus_handler_processed", "Number of transactions processed by consensus handler", &["class"], registry)
.unwrap()
}
}
}
Expand Down
23 changes: 21 additions & 2 deletions crates/sui-core/src/consensus_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use std::hash::{Hash, Hasher};
use std::sync::{Arc, Mutex};
use sui_types::base_types::{AuthorityName, EpochId, TransactionDigest};
use sui_types::messages::{
ConsensusTransaction, ConsensusTransactionKey, VerifiedExecutableTransaction,
VerifiedTransaction,
ConsensusTransaction, ConsensusTransactionKey, ConsensusTransactionKind,
VerifiedExecutableTransaction, VerifiedTransaction,
};
use sui_types::storage::ParentSync;
use tracing::{debug, error, instrument};
Expand Down Expand Up @@ -136,6 +136,10 @@ impl<T: ParentSync + Send + Sync> ExecutionState for ConsensusHandler<T> {
continue;
}
};
self.metrics
.consensus_handler_processed
.with_label_values(&[classify(&transaction)])
.inc();
let transaction = SequencedConsensusTransactionKind::External(transaction);
transactions.push((serialized_transaction, transaction, output_cert.clone()));
}
Expand Down Expand Up @@ -226,6 +230,21 @@ impl<T> ConsensusHandler<T> {
}
}

fn classify(transaction: &ConsensusTransaction) -> &'static str {
match &transaction.kind {
ConsensusTransactionKind::UserTransaction(certificate) => {
if certificate.contains_shared_object() {
"shared_certificate"
} else {
"owned_certificate"
}
}
ConsensusTransactionKind::CheckpointSignature(_) => "checkpoint_signature",
ConsensusTransactionKind::EndOfPublish(_) => "end_of_publish",
ConsensusTransactionKind::CapabilityNotification(_) => "capability_notification",
}
}

pub struct SequencedConsensusTransaction {
pub certificate: Arc<narwhal_types::Certificate>,
pub consensus_index: ExecutionIndicesWithHash,
Expand Down

0 comments on commit 91b6e22

Please sign in to comment.