Add more fine grained counters (#683)

Fixes #665
This commit is contained in:
Alex Kremer
2023-06-09 16:48:55 +01:00
committed by GitHub
parent 9d28e64383
commit b83d206ced
15 changed files with 454 additions and 502 deletions

View File

@@ -23,13 +23,22 @@
namespace RPC {
void
Counters::rpcFailed(std::string const& method)
{
std::scoped_lock lk(mutex_);
MethodInfo& counters = methodInfo_[method];
++counters.started;
++counters.failed;
}
void
Counters::rpcErrored(std::string const& method)
{
std::scoped_lock lk(mutex_);
MethodInfo& counters = methodInfo_[method];
counters.started++;
counters.errored++;
++counters.started;
++counters.errored;
}
void
@@ -37,8 +46,8 @@ Counters::rpcComplete(std::string const& method, std::chrono::microseconds const
{
std::scoped_lock lk(mutex_);
MethodInfo& counters = methodInfo_[method];
counters.started++;
counters.finished++;
++counters.started;
++counters.finished;
counters.duration += rpcDuration.count();
}
@@ -47,7 +56,45 @@ Counters::rpcForwarded(std::string const& method)
{
std::scoped_lock lk(mutex_);
MethodInfo& counters = methodInfo_[method];
counters.forwarded++;
++counters.forwarded;
}
void
Counters::rpcFailedToForward(std::string const& method)
{
std::scoped_lock lk(mutex_);
MethodInfo& counters = methodInfo_[method];
++counters.failedForward;
}
void
Counters::onTooBusy()
{
++tooBusyCounter_;
}
void
Counters::onNotReady()
{
++notReadyCounter_;
}
void
Counters::onBadSyntax()
{
++badSyntaxCounter_;
}
void
Counters::onUnknownCommand()
{
++unknownCommandCounter_;
}
void
Counters::onInternalError()
{
++internalErrorCounter_;
}
boost::json::object
@@ -65,12 +112,20 @@ Counters::report() const
counters[JS(started)] = std::to_string(info.started);
counters[JS(finished)] = std::to_string(info.finished);
counters[JS(errored)] = std::to_string(info.errored);
counters[JS(failed)] = std::to_string(info.failed);
counters["forwarded"] = std::to_string(info.forwarded);
counters["failed_forward"] = std::to_string(info.failedForward);
counters[JS(duration_us)] = std::to_string(info.duration);
rpc[method] = std::move(counters);
}
obj["too_busy_errors"] = std::to_string(tooBusyCounter_);
obj["not_ready_errors"] = std::to_string(notReadyCounter_);
obj["bad_syntax_errors"] = std::to_string(badSyntaxCounter_);
obj["unknown_command_errors"] = std::to_string(unknownCommandCounter_);
obj["internal_errors"] = std::to_string(internalErrorCounter_);
obj["work_queue"] = workQueue_.get().report();
return obj;