Skip to content

Commit

Permalink
Add Monitoring Metrics to NebulaGraph vesoft-inc#5841
Browse files Browse the repository at this point in the history
  • Loading branch information
E2ern1ty committed Sep 6, 2024
1 parent cdeab59 commit 1a665cd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/graph/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
return pool->makeAndAdd<FulltextIndexScanExecutor>(node, qctx);
}
case PlanNode::Kind::kLimit: {
stats::StatsManager::addValue(kNumLimitExecutors);
if (FLAGS_enable_space_level_metrics && spaceName != "") {
stats::StatsManager::addValue(
stats::StatsManager::counterWithLabels(kNumLimitExecutors, {{"space", spaceName}}));
}
return pool->makeAndAdd<LimitExecutor>(node, qctx);
}
case PlanNode::Kind::kSample: {
Expand Down
12 changes: 11 additions & 1 deletion src/graph/executor/query/LimitExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#include "graph/executor/query/LimitExecutor.h"

#include "graph/planner/plan/Query.h"

#include "graph/stats/GraphStats.h"
namespace nebula {
namespace graph {

folly::Future<Status> LimitExecutor::execute() {
auto start_ts = std::chrono::steady_clock::now();
auto &spaceName = qctx()->rctx() ? qctx()->rctx()->session()->spaceName() : "";
SCOPED_TIMER(&execTime_);

auto* limit = asNode<Limit>(node());
Expand All @@ -31,6 +33,14 @@ folly::Future<Status> LimitExecutor::execute() {
builder.value(result.valuePtr());
iter->select(offset, count);
builder.iter(std::move(result).iter());
auto diff = std::chrono::steady_clock::now() - start_ts;
stats::StatsManager::addValue(
kLimitExecutorsLatencyUs,
std::chrono::duration_cast<std::chrono::milliseconds>(diff).count());
if (FLAGS_enable_space_level_metrics && spaceName != "") {
stats::StatsManager::addValue(
stats::StatsManager::histoWithLabels(kLimitExecutorsLatencyUs, {{"space", spaceName}}));
}
return finish(builder.build());
} else {
DataSet ds;
Expand Down
6 changes: 6 additions & 0 deletions src/graph/stats/GraphStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ stats::CounterId kOptimizerLatencyUs;

stats::CounterId kNumAggregateExecutors;
stats::CounterId kNumSortExecutors;
stats::CounterId kNumLimitExecutors;
stats::CounterId kLimitExecutorsLatencyUs;
stats::CounterId kNumIndexScanExecutors;

stats::CounterId kNumOpenedSessions;
Expand Down Expand Up @@ -66,6 +68,10 @@ void initGraphStats() {
kNumIndexScanExecutors =
stats::StatsManager::registerStats("num_indexscan_executors", "rate, sum");

kNumLimitExecutors = stats::StatsManager::registerStats("num_Limit_executors", "rate, sum");
kLimitExecutorsLatencyUs = stats::StatsManager::registerHisto(
"limit_executors_latency_us", 1000, 0, 2000, "avg, p75, p95, p99, p999");

kNumOpenedSessions = stats::StatsManager::registerStats("num_opened_sessions", "rate, sum");
kNumAuthFailedSessions =
stats::StatsManager::registerStats("num_auth_failed_sessions", "rate, sum");
Expand Down
2 changes: 2 additions & 0 deletions src/graph/stats/GraphStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ extern stats::CounterId kOptimizerLatencyUs;
// Executor
extern stats::CounterId kNumAggregateExecutors;
extern stats::CounterId kNumSortExecutors;
extern stats::CounterId kNumLimitExecutors;
extern stats::CounterId kLimitExecutorsLatencyUs;
extern stats::CounterId kNumIndexScanExecutors;

// Server client traffic
Expand Down

0 comments on commit 1a665cd

Please sign in to comment.