22#include "rpc/WorkQueue.hpp"
23#include "util/prometheus/Counter.hpp"
24#include "util/prometheus/Histogram.hpp"
26#include <boost/json.hpp>
27#include <boost/json/object.hpp>
34#include <unordered_map>
42 using CounterType = std::reference_wrapper<util::prometheus::CounterInt>;
47 MethodInfo(std::string
const& method);
53 CounterType forwarded;
54 CounterType failedForward;
59 getMethodInfo(std::string
const& method);
61 mutable std::mutex mutex_;
62 std::unordered_map<std::string, MethodInfo> methodInfo_;
65 CounterType tooBusyCounter_;
66 CounterType notReadyCounter_;
67 CounterType badSyntaxCounter_;
68 CounterType unknownCommandCounter_;
69 CounterType internalErrorCounter_;
71 std::reference_wrapper<util::prometheus::HistogramInt> ledgerAgeLedgersHistogram_;
72 CounterType ledgerHashRequestsCounter_;
74 std::reference_wrapper<Reportable const> workQueue_;
75 std::chrono::time_point<std::chrono::system_clock> startupTime_;
120 rpcComplete(std::string
const& method, std::chrono::microseconds
const& rpcDuration);
165 recordLedgerRequest(boost::json::object
const& params, std::uint32_t currentLedgerSequence);
void rpcComplete(std::string const &method, std::chrono::microseconds const &rpcDuration)
Increments the completed count for a particular RPC method.
Definition Counters.cpp:186
void onNotReady()
Increments the global not ready counter.
Definition Counters.cpp:218
void rpcForwarded(std::string const &method)
Increments the forwarded count for a particular RPC method.
Definition Counters.cpp:196
void rpcFailedToForward(std::string const &method)
Increments the failed to forward count for a particular RPC method.
Definition Counters.cpp:204
void recordLedgerRequest(boost::json::object const ¶ms, std::uint32_t currentLedgerSequence)
Records ledger request metrics based on the ledger parameter in the request.
Definition Counters.cpp:242
static Counters makeCounters(WorkQueue const &wq)
A factory function that creates a new counters instance.
Definition Counters.hpp:92
void onInternalError()
Increments the global internal error counter.
Definition Counters.cpp:236
std::chrono::seconds uptime() const
Definition Counters.cpp:271
void rpcFailed(std::string const &method)
Increments the failed count for a particular RPC method.
Definition Counters.cpp:168
boost::json::object report() const
Definition Counters.cpp:279
void onTooBusy()
Increments the global too busy counter.
Definition Counters.cpp:212
void onBadSyntax()
Increments the global bad syntax counter.
Definition Counters.cpp:224
void onUnknownCommand()
Increments the global unknown command/method counter.
Definition Counters.cpp:230
void rpcErrored(std::string const &method)
Increments the errored count for a particular RPC method.
Definition Counters.cpp:177
Counters(Reportable const &wq)
Creates a new counters instance that operates on the given WorkQueue.
Definition Counters.cpp:111
An asynchronous, thread-safe queue for RPC requests.
Definition WorkQueue.hpp:62
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:37
An interface for any class providing a report as json object.
Definition WorkQueue.hpp:47