From 2c7ecfa01f93849bd6b644e1c3b6770697b7039d Mon Sep 17 00:00:00 2001 From: Doodle <13706157+critical27@users.noreply.github.com> Date: Thu, 10 Feb 2022 09:52:53 +0800 Subject: [PATCH] add snapshot metric --- src/kvstore/raftex/Host.cpp | 1 + src/kvstore/stats/KVStats.cpp | 2 ++ src/kvstore/stats/KVStats.h | 1 + 3 files changed, 4 insertions(+) diff --git a/src/kvstore/raftex/Host.cpp b/src/kvstore/raftex/Host.cpp index 2e89c210742..499752f846e 100644 --- a/src/kvstore/raftex/Host.cpp +++ b/src/kvstore/raftex/Host.cpp @@ -339,6 +339,7 @@ nebula::cpp2::ErrorCode Host::startSendSnapshot() { << ", firstLogId in wal = " << part_->wal()->firstLogId() << ", lastLogId in wal = " << part_->wal()->lastLogId(); sendingSnapshot_ = true; + stats::StatsManager::addValue(kNumSendSnapshot); part_->snapshot_->sendSnapshot(part_, addr_) .thenValue([self = shared_from_this()](auto&& status) { std::lock_guard g(self->lock_); diff --git a/src/kvstore/stats/KVStats.cpp b/src/kvstore/stats/KVStats.cpp index 2e379e912b3..a6a152e404e 100644 --- a/src/kvstore/stats/KVStats.cpp +++ b/src/kvstore/stats/KVStats.cpp @@ -18,6 +18,7 @@ stats::CounterId kAppendLogLatencyUs; stats::CounterId kTransferLeaderLatencyUs; stats::CounterId kNumStartElect; stats::CounterId kNumGrantVotes; +stats::CounterId kNumSendSnapshot; void initKVStats() { kCommitLogLatencyUs = stats::StatsManager::registerHisto( @@ -34,6 +35,7 @@ void initKVStats() { "transfer_leader_latency_us", 1000, 0, 2000, "avg, p75, p95, p99, p999"); kNumStartElect = stats::StatsManager::registerStats("num_start_elect", "rate, sum"); kNumGrantVotes = stats::StatsManager::registerStats("num_grant_votes", "rate, sum"); + kNumSendSnapshot = stats::StatsManager::registerStats("num_send_snapshot", "rate, sum"); } } // namespace nebula diff --git a/src/kvstore/stats/KVStats.h b/src/kvstore/stats/KVStats.h index 4d21b68c530..53096327428 100644 --- a/src/kvstore/stats/KVStats.h +++ b/src/kvstore/stats/KVStats.h @@ -19,6 +19,7 @@ extern stats::CounterId kAppendLogLatencyUs; extern stats::CounterId kTransferLeaderLatencyUs; extern stats::CounterId kNumStartElect; extern stats::CounterId kNumGrantVotes; +extern stats::CounterId kNumSendSnapshot; void initKVStats();