Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

Commit b27ac99

Browse files
author
Eason Gao
authored
feat(apm): add executing block num to apm (#429)
* feat: add executing block num to apm * refactor
1 parent dae62ae commit b27ac99

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

common/apm/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All current metrics and usage
99
| muta_api_request_time_cost_seconds | histogram | |
1010

1111

12-
## Consensus
12+
## Consensus
1313
<table>
1414
<thead>
1515
<tr>
@@ -37,6 +37,11 @@ All current metrics and usage
3737
<td>gauge</td>
3838
<td>consensus_round_cost</td>
3939
</tr>
40+
<tr>
41+
<td>muta_executing_queue</td>
42+
<td>gauge</td>
43+
<td>executing_block_size</td>
44+
</tr>
4045
<tr>
4146
<td rowspan="3">muta_consensus_height</td>
4247
<td rowspan="3">gauge</td>

common/apm/src/metrics/consensus.rs

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ lazy_static! {
6565
register_int_gauge!("muta_consensus_round", "Round count of consensus").unwrap();
6666
pub static ref ENGINE_HEIGHT_GAUGE: IntGauge =
6767
register_int_gauge!("muta_consensus_height", "Height of muta").unwrap();
68+
pub static ref ENGINE_EXECUTING_BLOCK_GAUGE: IntGauge =
69+
register_int_gauge!("muta_executing_block_count", "The executing blocks").unwrap();
6870
pub static ref ENGINE_COMMITED_TX_COUNTER: IntCounter = register_int_counter!(
6971
"muta_consensus_committed_tx_total",
7072
"The committed transactions"

core/consensus/src/status.rs

+6
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ impl CurrentConsensusStatus {
117117
self.list_confirm_root.push(info.confirm_root.clone());
118118
self.list_receipt_root.push(info.receipt_root.clone());
119119
self.list_state_root.push(info.state_root);
120+
121+
common_apm::metrics::consensus::ENGINE_EXECUTING_BLOCK_GAUGE
122+
.set(self.latest_committed_height as i64 - self.exec_height as i64);
120123
}
121124

122125
pub(crate) fn update_by_committed(
@@ -136,6 +139,9 @@ impl CurrentConsensusStatus {
136139
self.latest_committed_state_root = block.header.state_root.clone();
137140

138141
self.split_off(&block);
142+
143+
common_apm::metrics::consensus::ENGINE_EXECUTING_BLOCK_GAUGE
144+
.set((self.latest_committed_height - self.exec_height) as i64);
139145
}
140146

141147
pub(crate) fn set_metadata(&mut self, metadata: Metadata) {

0 commit comments

Comments
 (0)