8000 missing metrics (#10625) · arangodb/arangodb@376a8cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 376a8cc

Browse files
kvahedjsteemannSimran-B
authored
missing metrics (#10625)
* some missing metrics * added the missing from startistics * minimise reallocs * Update MetricsFeature.cpp * all in * oh my * logarithmic histogram * rewrote the whole interface of logarithmic histograms to accomodate arbitrary basis. * log output * log tests * log tests * more tests * metrics fixing on * added tests * corrected prometheus export * log tests * metrics with label discrimination * metrics with label discrimination * only counters outstanding with new key scheme * only counters outstanding with new key scheme * only counters outstanding with new key scheme * fixed label behaviour * corrected retrieve bahaviour. * feature tests * feature tests * fetching bug * fixed uint64_t * wtf * histogram count labels * histogram feature tests * histogram feature tests * gauge feature tests * long int ambiguity * windows warning * separator on wrong side * windows warnings * added role to labels * http requests * added agency commit histogram * could break won't anymore Co-authored-by: Jan <jsteemann@users.noreply.github.com> Co-authored-by: Simran <Simran-B@users.noreply.github.com>
1 parent 4ced7d3 commit 376a8cc

14 files changed

+1205
-206
lines changed

arangod/Agency/Agent.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,18 @@ Agent::Agent(ApplicationServer& server, config_t const& config)
8383
"agency_agent_write_no_leader", 0, "Agency write no leader")),
8484
_read_ok(
8585
_server.getFeature<arangodb::MetricsFeature>().counter(
86-
"agency_agent_read_ok", 0, "Agency write ok")),
86+
"agency_agent_read_ok", 0, "Agency read ok")),
8787
_read_no_leader(
8888
_server.getFeature<arangodb::MetricsFeature>().counter(
89-
"agency_agent_read_no_leader", 0, "Agency write no leader")),
89+
"agency_agent_read_no_leader", 0, "Agency read no leader")),
9090
_write_hist_msec(
9191
_server.getFeature<arangodb::MetricsFeature>().histogram(
92-
"agency_agent_write_hist", 10, 0., 20., "Agency write histogram [ms]")) {
92+
"agency_agent_write_hist", log_scale_t(2.f, 0.f, 200.f, 10),
93+
"Agency write histogram [ms]")),
94+
_commit_hist_msec(
95+
_server.getFeature<arangodb::MetricsFeature>().histogram(
96+
"agency_agent_commit_hist", log_scale_t(std::exp(1.f), 0.f, 200.f, 10),
97+
"Agency RAFT commit histogram [ms]")) {
9398
_state.configure(this);
9499
_constituent.configure(this);
95100
if (size() > 1) {
@@ -102,6 +107,11 @@ Agent::Agent(ApplicationServer& server, config_t const& config)
102107
/// This agent's id
103108
std::string Agent::id() const { return _config.id(); }
104109

110+
// Under no circumstances guard the member. Metrics guard themselves.
111+
decltype(Agent::_commit_hist_msec) Agent::commitHist() const {
112+
return _commit_hist_msec;
113+
}
114+
105115
/// Agent's id is set once from state machine
106116
bool Agent::id(std::string const& id) {
107117
bool success;
@@ -1229,7 +1239,7 @@ write_ret_t Agent::write(query_t const& query, WriteMode const& wmode) {
12291239
indices.insert(indices.end(), tmp.begin(), tmp.end());
12301240
}
12311241
_write_hist_msec.count(
1232-
duration<double,std::milli>(high_resolution_clock::now()-start).count());
1242+
duration<float,std::milli>(high_resolution_clock::now()-start).count());
12331243
}
12341244

12351245
// Maximum log index
@@ -1284,7 +1294,7 @@ read_ret_t Agent::read(query_t const& query) {
12841294
// Retrieve data from readDB
12851295
std::vector<bool> success = _readDB.read(query, result);
12861296

1287-
++_read_no_leader;
1297+
++_read_ok;
12881298
return read_ret_t(true, leader, std::move(success), std::move(result));
12891299
}
12901300

arangod/Agency/Agent.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ class Agent final : public arangodb::Thread, public AgentInterface {
339339
/// the agency leader.
340340
void updateSomeConfigValues(VPackSlice);
341341

342+
Histogram<log_scale_t<float>>& commitHist() const;
343+
342344
private:
343345

344346
/// @brief load() has run
@@ -507,7 +509,8 @@ class Agent final : public arangodb::Thread, public AgentInterface {
507509
Counter& _write_no_leader;
508510
Counter& _read_ok;
509511
Counter& _read_no_leader;
510-
Histogram<double>& _write_hist_msec;
512+
Histogram<log_scale_t<float>>& _write_hist_msec;
513+
Histogram<log_scale_t<float>>& _commit_hist_msec;
511514

512515
};
513516
} // namespace consensus

arangod/Agency/RestAgencyHandler.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ RestStatus RestAgencyHandler::handleStore() {
209209
}
210210

211211
RestStatus RestAgencyHandler::handleWrite() {
212+
213+
using namespace std::chrono;
212214
if (_request->requestType() != rest::RequestType::POST) {
213215
return reportMethodNotAllowed();
214216
}
@@ -238,6 +240,9 @@ RestStatus RestAgencyHandler::handleWrite() {
238240
return reportMessage(rest::ResponseCode::SERVICE_UNAVAILABLE, "No leader");
239241
}
240242

243+
// Start timing
244+
auto const start = high_resolution_clock::now();
245+
241246
// Do write
242247
write_ret_t ret;
243248
try {
@@ -295,6 +300,8 @@ RestStatus RestAgencyHandler::handleWrite() {
295300

296301
if (max_index > 0) {
297302
result = _agent->waitFor(max_index);
303+
_agent->commitHist().count(
304+
duration<float,std::milli>(high_resolution_clock::now()-start).count());
298305
}
299306
}
300307
}

arangod/Cluster/ServerState.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,10 @@ std::string ServerState::roleToAgencyKey(ServerState::RoleEnum role) {
492492
return "Coordinator";
493493
case ROLE_SINGLE:
494494
return "Single";
495-
496-
case ROLE_UNDEFINED:
497-
case ROLE_AGENT: {
498-
TRI_ASSERT(false);
495+
case ROLE_AGENT:
496+
return "Agent";
497+
case ROLE_UNDEFINED: {
498+
return "Undefined";
499499
}
500500
}
501501
return "INVALID_CLUSTER_ROLE";
@@ -740,6 +740,14 @@ bool ServerState::registerAtAgencyPhase1(AgencyComm& comm, ServerState::RoleEnum
740740
return false;
741741
}
742742

743+
std::string ServerState::getShortName() const {
744+
std::stringstream ss; // ShortName
745+
auto num = getShortId();
746+
size_t width = std::max(std::to_string(num + 1).size(), static_cast<size_t>(4));
747+
ss << roleToAgencyKey(getRole()) << std::setw(width) << std::setfill('0') << num + 1;
748+
return ss.str();
749+
}
750+
743751
bool ServerState::registerAtAgencyPhase2(AgencyComm& comm, bool const hadPersistedId) {
744752
TRI_ASSERT(!_id.empty() && !_myEndpoint.empty());
745753

arangod/Cluster/ServerState.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ class ServerState {
212212
/// @brief set the server short id
213213
void setShortId(uint32_t);
214214

215+
/// @brief set the server short id
216+
std::string getShortName() const;
217+
215218
RebootId getRebootId() const;
216219

217220
void setRebootId(RebootId rebootId);

arangod/RestServer/Metrics.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ std::ostream& operator<< (std::ostream& o, Metrics::hist_type const& v) {
4848
return o;
4949
}
5050

51-
Metric::Metric(std::string const& name, std::string const& help)
52-
: _name(name), _help(help) {};
51+
Metric::Metric(std::string const& name, std::string const& help, std::string const& labels)
52+
: _name(name), _help(help), _labels(labels) {};
5353

5454
Metric::~Metric() {}
5555

5656
std::string const& Metric::help() const { return _help; }
5757
std::string const& Metric::name() const { return _name; }
58+
std::string const& Metric::labels() const { return _labels; }
5859

5960
Counter& Counter::operator++() {
6061
count();
@@ -102,12 +103,13 @@ void Counter::toPrometheus(std::string& result) const {
102103
_b.push();
103104
result += "#TYPE " + name() + " counter\n";
104105
result += "#HELP " + name() + " " + help() + "\n";
105-
result += name() + " " + std::to_string(load()) + "\n";
106+
result += name() + "{" + labels() + "} " + std::to_string(load()) + "\n";
106107
}
107108

108109
Counter::Counter(
109-
uint64_t const& val, std::string const& name, std::string const& help) :
110-
Metric(name, help), _c(val), _b(_c) {}
110+
uint64_t const& val, std::string const& name, std::string const& help,
111+
std::string const& labels) :
112+
Metric(name, help, labels), _c(val), _b(_c) {}
111113

112114
Counter::~Counter() { _b.push(); }
113115

0 commit comments

Comments
 (0)
0