3#include "rpc/WorkQueue.hpp"
4#include "util/prometheus/Counter.hpp"
5#include "util/prometheus/Histogram.hpp"
7#include <boost/json.hpp>
8#include <boost/json/object.hpp>
15#include <unordered_map>
23 using CounterType = std::reference_wrapper<util::prometheus::CounterInt>;
28 MethodInfo(std::string
const& method);
34 CounterType forwarded;
35 CounterType failedForward;
40 getMethodInfo(std::string
const& method);
42 mutable std::mutex mutex_;
43 std::unordered_map<std::string, MethodInfo> methodInfo_;
46 CounterType tooBusyCounter_;
47 CounterType notReadyCounter_;
48 CounterType badSyntaxCounter_;
49 CounterType unknownCommandCounter_;
50 CounterType internalErrorCounter_;
52 std::reference_wrapper<util::prometheus::HistogramInt> ledgerAgeLedgersHistogram_;
53 CounterType ledgerHashRequestsCounter_;
55 std::reference_wrapper<Reportable const> workQueue_;
56 std::chrono::time_point<std::chrono::system_clock> startupTime_;
101 rpcComplete(std::string
const& method, std::chrono::microseconds
const& rpcDuration);
146 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:167
void onNotReady()
Increments the global not ready counter.
Definition Counters.cpp:199
void rpcForwarded(std::string const &method)
Increments the forwarded count for a particular RPC method.
Definition Counters.cpp:177
void rpcFailedToForward(std::string const &method)
Increments the failed to forward count for a particular RPC method.
Definition Counters.cpp:185
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:223
static Counters makeCounters(WorkQueue const &wq)
A factory function that creates a new counters instance.
Definition Counters.hpp:73
void onInternalError()
Increments the global internal error counter.
Definition Counters.cpp:217
std::chrono::seconds uptime() const
Definition Counters.cpp:252
void rpcFailed(std::string const &method)
Increments the failed count for a particular RPC method.
Definition Counters.cpp:149
boost::json::object report() const
Definition Counters.cpp:260
void onTooBusy()
Increments the global too busy counter.
Definition Counters.cpp:193
void onBadSyntax()
Increments the global bad syntax counter.
Definition Counters.cpp:205
void onUnknownCommand()
Increments the global unknown command/method counter.
Definition Counters.cpp:211
void rpcErrored(std::string const &method)
Increments the errored count for a particular RPC method.
Definition Counters.cpp:158
Counters(Reportable const &wq)
Creates a new counters instance that operates on the given WorkQueue.
Definition Counters.cpp:92
An asynchronous, thread-safe queue for RPC requests.
Definition WorkQueue.hpp:43
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18
An interface for any class providing a report as json object.
Definition WorkQueue.hpp:28