Skip to content

Commit

Permalink
store: add region metrics for ready. (tikv#1832)
Browse files Browse the repository at this point in the history
  • Loading branch information
siddontang authored May 12, 2017
1 parent d3ae3ca commit b644e99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/raftstore/store/local_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct RaftReadyMetrics {
pub commit: u64,
pub append: u64,
pub snapshot: u64,
pub pending_region: u64,
pub has_ready_region: u64,
}

impl RaftReadyMetrics {
Expand Down Expand Up @@ -53,6 +55,18 @@ impl RaftReadyMetrics {
.unwrap();
self.snapshot = 0;
}
if self.pending_region > 0 {
STORE_RAFT_READY_COUNTER_VEC.with_label_values(&["pending_region"])
.inc_by(self.pending_region as f64)
.unwrap();
self.pending_region = 0;
}
if self.has_ready_region > 0 {
STORE_RAFT_READY_COUNTER_VEC.with_label_values(&["has_ready_region"])
.inc_by(self.has_ready_region as f64)
.unwrap();
self.has_ready_region = 0;
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/raftstore/store/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,8 @@ impl<T: Transport, C: PdClient> Store<T, C> {
let previous_ready_metrics = self.raft_metrics.ready.clone();
let previous_sent_snapshot_count = self.raft_metrics.message.snapshot;

self.raft_metrics.ready.pending_region += pending_count as u64;

let (wb, append_res) = {
let mut ctx = ReadyContext::new(&mut self.raft_metrics, &self.trans, pending_count);
for region_id in self.pending_raft_groups.drain() {
Expand All @@ -893,6 +895,8 @@ impl<T: Transport, C: PdClient> Store<T, C> {
(ctx.wb, ctx.ready_res)
};

self.raft_metrics.ready.has_ready_region += append_res.len() as u64;

if !wb.is_empty() {
self.engine.write(wb).unwrap_or_else(|e| {
panic!("{} failed to save append result: {:?}", self.tag, e);
Expand Down

0 comments on commit b644e99

Please sign in to comment.