From ad35c9e27050dfe9ecfd5b315d0dc017440d80d4 Mon Sep 17 00:00:00 2001 From: Huang Wei Date: Tue, 14 Nov 2023 17:18:19 +0800 Subject: [PATCH] fix --- docs/zh/maintain/monitoring.md | 2 +- .../deployment_metric_collector.h | 10 ++++++---- .../deployment_metric_collector_test.cc | 17 +++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/zh/maintain/monitoring.md b/docs/zh/maintain/monitoring.md index 5ae98d22c8b..e51f0a3b8bc 100644 --- a/docs/zh/maintain/monitoring.md +++ b/docs/zh/maintain/monitoring.md @@ -212,7 +212,7 @@ OpenMLDB 的相关组件(即 nameserver, tablet, etc), 本身作为 BRPC ser - BRPC server 进程相关信息 - 对应 BRPC server 定义的 RPC method 相关指标,例如该 RPC 的请求 `count`, `error_count`, `qps` 和 `response_time` - - Deployment 相关指标,分deployment统计,但只统计该tablet上的deployment请求。它们将通过Prometheus relabel和Grafana聚合,形成最终的的集群级别Deployment指标。 + - Deployment 相关指标,分deployment统计,但只统计该tablet上的deployment请求。它们将通过Grafana聚合,形成最终的的集群级别Deployment指标。 通过 diff --git a/src/statistics/query_response_time/deployment_metric_collector.h b/src/statistics/query_response_time/deployment_metric_collector.h index da93045ba08..9296b5a5fde 100644 --- a/src/statistics/query_response_time/deployment_metric_collector.h +++ b/src/statistics/query_response_time/deployment_metric_collector.h @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef SRC_STATISTICS_DEPLOYMENT_METRIC_COLLECTOR_H_ -#define SRC_STATISTICS_DEPLOYMENT_METRIC_COLLECTOR_H_ +#ifndef SRC_STATISTICS_QUERY_RESPONSE_TIME_DEPLOYMENT_METRIC_COLLECTOR_H_ +#define SRC_STATISTICS_QUERY_RESPONSE_TIME_DEPLOYMENT_METRIC_COLLECTOR_H_ +#include +#include #include #include @@ -31,7 +33,7 @@ namespace openmldb::statistics { class DeploymentMetricCollector { public: typedef typename bvar::MultiDimension MDRecorder; - DeploymentMetricCollector(const std::string& prefix) : prefix_(prefix), md_recorder_(make_shared(prefix)) { + explicit DeploymentMetricCollector(const std::string& prefix) : prefix_(prefix), md_recorder_(make_shared(prefix)) { // already expose_as when MultiDimension ctor } // collector is not copyable @@ -76,4 +78,4 @@ class DeploymentMetricCollector { mutable absl::Mutex mutex_; // protects collectors_ }; } // namespace openmldb::statistics -#endif // SRC_STATISTICS_DEPLOYMENT_METRIC_COLLECTOR_H_ +#endif // SRC_STATISTICS_QUERY_RESPONSE_TIME_DEPLOYMENT_METRIC_COLLECTOR_H_ diff --git a/src/statistics/query_response_time/deployment_metric_collector_test.cc b/src/statistics/query_response_time/deployment_metric_collector_test.cc index 6ca18839a69..06ae0e0ddd4 100644 --- a/src/statistics/query_response_time/deployment_metric_collector_test.cc +++ b/src/statistics/query_response_time/deployment_metric_collector_test.cc @@ -16,10 +16,11 @@ #include "statistics/query_response_time/deployment_metric_collector.h" +#include +#include #include #include #include -#include #include "absl/random/random.h" #include "absl/strings/str_cat.h" @@ -29,9 +30,6 @@ #include "glog/logging.h" #include "gtest/gtest.h" -#include -#include - namespace bvar { DECLARE_int32(bvar_dump_interval); } @@ -45,7 +43,10 @@ class CollectorTest : public ::testing::Test { ~CollectorTest() override = default; }; -using namespace std; +using std::ifstream; +using std::string; +using std::ios_base; + void mem_usage() { double vm_usage = 0.0; double resident_set = 0.0; @@ -55,13 +56,13 @@ void mem_usage() { string tpgid, flags, minflt, cminflt, majflt, cmajflt; string utime, stime, cutime, cstime, priority, nice; string O, itrealvalue, starttime; - unsigned long vsize; - long rss; + uint64_t vsize; + int64_t rss; stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt >> utime >> stime >> cutime >> cstime >> priority >> nice >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest stat_stream.close(); - long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // for x86-64 is configured to use 2MB pages + int64_t page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // for x86-64 is configured to use 2MB pages vm_usage = vsize / 1024.0; resident_set = rss * page_size_kb; LOG(INFO) << "VM: " << vm_usage << "KB; RSS: " << resident_set << "KB";