mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
@@ -40,13 +40,11 @@ Counters::initializeCounter(std::string const& method)
|
||||
void
|
||||
Counters::rpcErrored(std::string const& method)
|
||||
{
|
||||
if (!validHandler(method))
|
||||
return;
|
||||
|
||||
initializeCounter(method);
|
||||
|
||||
std::shared_lock lk(mutex_);
|
||||
MethodInfo& counters = methodInfo_[method];
|
||||
|
||||
counters.started++;
|
||||
counters.errored++;
|
||||
}
|
||||
@@ -54,13 +52,11 @@ Counters::rpcErrored(std::string const& method)
|
||||
void
|
||||
Counters::rpcComplete(std::string const& method, std::chrono::microseconds const& rpcDuration)
|
||||
{
|
||||
if (!validHandler(method))
|
||||
return;
|
||||
|
||||
initializeCounter(method);
|
||||
|
||||
std::shared_lock lk(mutex_);
|
||||
MethodInfo& counters = methodInfo_[method];
|
||||
|
||||
counters.started++;
|
||||
counters.finished++;
|
||||
counters.duration += rpcDuration.count();
|
||||
@@ -69,13 +65,11 @@ Counters::rpcComplete(std::string const& method, std::chrono::microseconds const
|
||||
void
|
||||
Counters::rpcForwarded(std::string const& method)
|
||||
{
|
||||
if (!validHandler(method))
|
||||
return;
|
||||
|
||||
initializeCounter(method);
|
||||
|
||||
std::shared_lock lk(mutex_);
|
||||
MethodInfo& counters = methodInfo_[method];
|
||||
|
||||
counters.forwarded++;
|
||||
}
|
||||
|
||||
@@ -83,13 +77,14 @@ boost::json::object
|
||||
Counters::report() const
|
||||
{
|
||||
std::shared_lock lk(mutex_);
|
||||
boost::json::object obj = {};
|
||||
auto obj = boost::json::object{};
|
||||
|
||||
obj[JS(rpc)] = boost::json::object{};
|
||||
auto& rpc = obj[JS(rpc)].as_object();
|
||||
|
||||
for (auto const& [method, info] : methodInfo_)
|
||||
{
|
||||
boost::json::object counters = {};
|
||||
auto counters = boost::json::object{};
|
||||
counters[JS(started)] = std::to_string(info.started);
|
||||
counters[JS(finished)] = std::to_string(info.finished);
|
||||
counters[JS(errored)] = std::to_string(info.errored);
|
||||
@@ -98,6 +93,7 @@ Counters::report() const
|
||||
|
||||
rpc[method] = std::move(counters);
|
||||
}
|
||||
|
||||
obj["work_queue"] = workQueue_.get().report();
|
||||
|
||||
return obj;
|
||||
|
||||
Reference in New Issue
Block a user