From 59e54d67e6356d7030bc4dc6767eec8d4a9c5dc0 Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 5 Dec 2019 10:03:28 +0800 Subject: [PATCH] feat(collector): add statistics for estimate key number of table (#437) --- src/server/info_collector.cpp | 3 +++ src/server/info_collector.h | 1 + src/shell/command_helper.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/src/server/info_collector.cpp b/src/server/info_collector.cpp index 15a86b8452..cd084fbadf 100644 --- a/src/server/info_collector.cpp +++ b/src/server/info_collector.cpp @@ -167,6 +167,7 @@ void info_collector::on_app_stat() all.rdb_block_cache_total_count += row.rdb_block_cache_total_count; all.rdb_index_and_filter_blocks_mem_usage += row.rdb_index_and_filter_blocks_mem_usage; all.rdb_memtable_mem_usage += row.rdb_memtable_mem_usage; + all.rdb_estimate_num_keys += row.rdb_estimate_num_keys; read_qps[i] = row.get_qps + row.multi_get_qps + row.scan_qps; write_qps[i] = row.put_qps + row.multi_put_qps + row.remove_qps + row.multi_remove_qps + row.incr_qps + row.check_and_set_qps + row.check_and_mutate_qps; @@ -205,6 +206,7 @@ void info_collector::on_app_stat() counters->rdb_index_and_filter_blocks_mem_usage->set( row.rdb_index_and_filter_blocks_mem_usage); counters->rdb_memtable_mem_usage->set(row.rdb_memtable_mem_usage); + counters->rdb_estimate_num_keys->set(row.rdb_estimate_num_keys); counters->read_qps->set(read_qps[i]); counters->write_qps->set(write_qps[i]); } @@ -255,6 +257,7 @@ info_collector::AppStatCounters *info_collector::get_app_counters(const std::str INIT_COUNTER(rdb_block_cache_hit_rate); INIT_COUNTER(rdb_index_and_filter_blocks_mem_usage); INIT_COUNTER(rdb_memtable_mem_usage); + INIT_COUNTER(rdb_estimate_num_keys); INIT_COUNTER(read_qps); INIT_COUNTER(write_qps); _app_stat_counters[app_name] = counters; diff --git a/src/server/info_collector.h b/src/server/info_collector.h index 69e55e3904..da4144c3a8 100644 --- a/src/server/info_collector.h +++ b/src/server/info_collector.h @@ -53,6 +53,7 @@ class info_collector ::dsn::perf_counter_wrapper rdb_block_cache_mem_usage; ::dsn::perf_counter_wrapper rdb_index_and_filter_blocks_mem_usage; ::dsn::perf_counter_wrapper rdb_memtable_mem_usage; + ::dsn::perf_counter_wrapper rdb_estimate_num_keys; ::dsn::perf_counter_wrapper read_qps; ::dsn::perf_counter_wrapper write_qps; }; diff --git a/src/shell/command_helper.h b/src/shell/command_helper.h index e67cee1d97..a4878d84e8 100644 --- a/src/shell/command_helper.h +++ b/src/shell/command_helper.h @@ -538,6 +538,7 @@ struct row_data double rdb_block_cache_total_count = 0; double rdb_index_and_filter_blocks_mem_usage = 0; double rdb_memtable_mem_usage = 0; + double rdb_estimate_num_keys = 0; }; inline bool @@ -589,6 +590,8 @@ update_app_pegasus_perf_counter(row_data &row, const std::string &counter_name, row.rdb_index_and_filter_blocks_mem_usage += value; else if (counter_name == "rdb.memtable.memory_usage") row.rdb_memtable_mem_usage += value; + else if (counter_name == "rdb.estimate_num_keys") + row.rdb_estimate_num_keys += value; else return false; return true;