Skip to content

Commit

Permalink
Add lonely_block channel and unverified_block channel length
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Feb 4, 2024
1 parent aeb3816 commit 4233ae5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chain/src/chain_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ impl ChainService {
}
}

ckb_metrics::handle().map(|metrics| {
metrics
.ckb_chain_lonely_block_ch_len
.set(self.lonely_block_tx.len() as i64)
});

match self.lonely_block_tx.send(lonely_block) {
Ok(_) => {}
Err(SendError(lonely_block)) => {
Expand Down
5 changes: 5 additions & 0 deletions chain/src/consume_orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ impl ConsumeDescendantProcessor {
fn send_unverified_block(&self, lonely_block: LonelyBlockHash, total_difficulty: U256) {
let block_number = lonely_block.block_number_and_hash.number();
let block_hash = lonely_block.block_number_and_hash.hash();
ckb_metrics::handle().map(|metrics| {
metrics
.ckb_chain_unverified_block_ch_len
.set(self.unverified_blocks_tx.len() as i64)
});

match self.unverified_blocks_tx.send(lonely_block) {
Ok(_) => {
Expand Down
10 changes: 10 additions & 0 deletions util/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub struct Metrics {
pub ckb_chain_execute_callback_duration: Histogram,
/// ckb_chain orphan blocks count
pub ckb_chain_orphan_count: IntGauge,
pub ckb_chain_lonely_block_ch_len: IntGauge,
pub ckb_chain_unverified_block_ch_len: IntGauge,
/// ckb_sync_msg_process duration (seconds)
pub ckb_sync_msg_process_duration: HistogramVec,
/// ckb_sync_block_fetch duraiton (seconds)
Expand Down Expand Up @@ -157,6 +159,14 @@ static METRICS: once_cell::sync::Lazy<Metrics> = once_cell::sync::Lazy::new(|| {
"ckb_chain_orphan_count",
"The CKB chain orphan blocks count",
).unwrap(),
ckb_chain_lonely_block_ch_len: register_int_gauge!(
"ckb_chain_lonely_block_ch_len",
"The CKB chain lonely block channel length",
).unwrap(),
ckb_chain_unverified_block_ch_len: register_int_gauge!(
"ckb_chain_unverified_block_ch_len",
"The CKB chain unverified block channel length",
).unwrap(),
ckb_sync_msg_process_duration: register_histogram_vec!(
"ckb_sync_msg_process_duration",
"The CKB sync message process duration (seconds)",
Expand Down

0 comments on commit 4233ae5

Please sign in to comment.