Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Monitoring Metrics to NebulaGraph #5841 #5940

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading