mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 03:35:55 +00:00
add work queue output to server_info (#322)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include <rpc/Counters.h>
|
#include <rpc/Counters.h>
|
||||||
#include <rpc/RPC.h>
|
#include <rpc/RPC.h>
|
||||||
|
#include <rpc/RPCHelpers.h>
|
||||||
|
|
||||||
namespace RPC {
|
namespace RPC {
|
||||||
|
|
||||||
@@ -66,20 +67,23 @@ Counters::report()
|
|||||||
{
|
{
|
||||||
std::shared_lock lk(mutex_);
|
std::shared_lock lk(mutex_);
|
||||||
boost::json::object obj = {};
|
boost::json::object obj = {};
|
||||||
|
obj[JS(rpc)] = boost::json::object{};
|
||||||
|
auto& rpc = obj[JS(rpc)].as_object();
|
||||||
|
|
||||||
for (auto const& [method, info] : methodInfo_)
|
for (auto const& [method, info] : methodInfo_)
|
||||||
{
|
{
|
||||||
boost::json::object counters = {};
|
boost::json::object counters = {};
|
||||||
counters["started"] = std::to_string(info.started);
|
counters[JS(started)] = std::to_string(info.started);
|
||||||
counters["finished"] = std::to_string(info.finished);
|
counters[JS(finished)] = std::to_string(info.finished);
|
||||||
counters["errored"] = std::to_string(info.errored);
|
counters[JS(errored)] = std::to_string(info.errored);
|
||||||
counters["forwarded"] = std::to_string(info.forwarded);
|
counters["forwarded"] = std::to_string(info.forwarded);
|
||||||
counters["duration_us"] = std::to_string(info.duration);
|
counters[JS(duration_us)] = std::to_string(info.duration);
|
||||||
|
|
||||||
obj[method] = std::move(counters);
|
rpc[method] = std::move(counters);
|
||||||
}
|
}
|
||||||
|
obj["work_queue"] = workQueue_.get().report();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace RPC
|
} // namespace RPC
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <boost/json.hpp>
|
#include <boost/json.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <functional>
|
||||||
|
#include <rpc/WorkQueue.h>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -30,8 +32,10 @@ private:
|
|||||||
std::shared_mutex mutex_;
|
std::shared_mutex mutex_;
|
||||||
std::unordered_map<std::string, MethodInfo> methodInfo_;
|
std::unordered_map<std::string, MethodInfo> methodInfo_;
|
||||||
|
|
||||||
|
std::reference_wrapper<const WorkQueue> workQueue_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Counters() = default;
|
Counters(WorkQueue const& wq) : workQueue_(std::cref(wq)){};
|
||||||
|
|
||||||
void
|
void
|
||||||
rpcErrored(std::string const& method);
|
rpcErrored(std::string const& method);
|
||||||
@@ -50,4 +54,4 @@ public:
|
|||||||
|
|
||||||
} // namespace RPC
|
} // namespace RPC
|
||||||
|
|
||||||
#endif // RPC_COUNTERS_H
|
#endif // RPC_COUNTERS_H
|
||||||
|
|||||||
@@ -60,9 +60,8 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is not actually being called. Wait for application refactor
|
|
||||||
boost::json::object
|
boost::json::object
|
||||||
report()
|
report() const
|
||||||
{
|
{
|
||||||
boost::json::object obj;
|
boost::json::object obj;
|
||||||
obj["queued"] = queued_;
|
obj["queued"] = queued_;
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ doServerInfo(Context const& context)
|
|||||||
|
|
||||||
if (admin)
|
if (admin)
|
||||||
{
|
{
|
||||||
info[JS(counters)] = boost::json::object{};
|
info[JS(counters)] = context.counters.report();
|
||||||
info[JS(counters)].as_object()[JS(rpc)] = context.counters.report();
|
|
||||||
info[JS(counters)].as_object()["subscriptions"] =
|
info[JS(counters)].as_object()["subscriptions"] =
|
||||||
context.subscriptions->report();
|
context.subscriptions->report();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,6 +223,7 @@ public:
|
|||||||
, etl_(etl)
|
, etl_(etl)
|
||||||
, dosGuard_(dosGuard)
|
, dosGuard_(dosGuard)
|
||||||
, queue_(numWorkerThreads, maxQueueSize)
|
, queue_(numWorkerThreads, maxQueueSize)
|
||||||
|
, counters_(queue_)
|
||||||
{
|
{
|
||||||
boost::beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user