-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a29cd0
commit d79ed19
Showing
60 changed files
with
564 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ nebula_add_library( | |
stats_obj | ||
OBJECT | ||
StatsManager.cpp | ||
Stats.cpp | ||
) | ||
|
||
nebula_add_subdirectory(test) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include "stats/StatsManager.h" | ||
#include "stats/Stats.h" | ||
|
||
DEFINE_int32(histogram_bucketSize, 1000, "The width of each bucket"); | ||
DEFINE_uint32(histogram_min, 1, "The smallest value for the bucket range"); | ||
DEFINE_uint32(histogram_max, 1000 * 1000, "The largest value for the bucket range"); | ||
|
||
namespace nebula { | ||
namespace stats { | ||
|
||
Stats::Stats(const std::string& serverName, const std::string& moduleName) { | ||
qpsStatId_ = StatsManager::registerStats(serverName + "_" + moduleName + "_qps"); | ||
errorQpsStatId_ = StatsManager::registerStats(serverName + "_" + moduleName + "_error_qps"); | ||
latencyStatId_ = StatsManager::registerHisto(serverName + "_" + moduleName + "_latency", | ||
FLAGS_histogram_bucketSize, FLAGS_histogram_min, FLAGS_histogram_max); | ||
} | ||
|
||
// static | ||
void Stats::addStatsValue(const Stats *stats, bool ok, int64_t latency, uint32_t count) { | ||
if (stats == nullptr) { | ||
return; | ||
} | ||
if (ok && stats->getQpsStatId() != 0) { | ||
StatsManager::addValue(stats->getQpsStatId(), count); | ||
} | ||
if (!ok && stats->getErrorQpsStatId() != 0) { | ||
StatsManager::addValue(stats->getErrorQpsStatId(), count); | ||
} | ||
if (stats->getLatencyStatId() != 0) { | ||
StatsManager::addValue(stats->getLatencyStatId(), latency); | ||
} | ||
} | ||
|
||
int32_t Stats::getQpsStatId() const { | ||
return qpsStatId_; | ||
} | ||
|
||
int32_t Stats::getErrorQpsStatId() const { | ||
return errorQpsStatId_; | ||
} | ||
|
||
int32_t Stats::getLatencyStatId() const { | ||
return latencyStatId_; | ||
} | ||
|
||
} // namespace stats | ||
} // namespace nebula | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef COMMON_STATS_STATS_H_ | ||
#define COMMON_STATS_STATS_H_ | ||
|
||
#include "stats/StatsManager.h" | ||
|
||
namespace nebula { | ||
namespace stats { | ||
|
||
class Stats final { | ||
public: | ||
Stats() = default; | ||
~Stats() = default; | ||
|
||
explicit Stats(const std::string& serverName, const std::string& moduleName); | ||
|
||
public: | ||
static void addStatsValue(const Stats *stats, bool ok, int64_t latency = 0, uint32_t count = 1); | ||
|
||
int32_t getQpsStatId() const; | ||
|
||
int32_t getErrorQpsStatId() const; | ||
|
||
int32_t getLatencyStatId() const; | ||
|
||
private: | ||
int32_t qpsStatId_{0}; | ||
int32_t errorQpsStatId_{0}; | ||
int32_t latencyStatId_{0}; | ||
}; | ||
} // namespace stats | ||
} // namespace nebula | ||
|
||
#endif // COMMON_STATS_STATS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.