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