Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vagetablechicken committed Nov 14, 2023
1 parent 54ceb72 commit ad35c9e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/zh/maintain/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -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指标。

通过

Expand Down
10 changes: 6 additions & 4 deletions src/statistics/query_response_time/deployment_metric_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <list>
#include <memory>
#include <sstream>
#include <string>

Expand All @@ -31,7 +33,7 @@ namespace openmldb::statistics {
class DeploymentMetricCollector {
public:
typedef typename bvar::MultiDimension<bvar::LatencyRecorder> 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
Expand Down Expand Up @@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

#include "statistics/query_response_time/deployment_metric_collector.h"

#include <fstream>
#include <iostream>
#include <numeric>
#include <string>
#include <thread>
#include <vector>

#include "absl/random/random.h"
#include "absl/strings/str_cat.h"
Expand All @@ -29,9 +30,6 @@
#include "glog/logging.h"
#include "gtest/gtest.h"

#include <fstream>
#include <iostream>

namespace bvar {
DECLARE_int32(bvar_dump_interval);
}
Expand All @@ -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;
Expand All @@ -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";
Expand Down

0 comments on commit ad35c9e

Please sign in to comment.