3#include "util/prometheus/Counter.hpp"
4#include "util/prometheus/Gauge.hpp"
5#include "util/prometheus/Histogram.hpp"
7#include <boost/json/object.hpp>
25 { a.registerTooBusy() } -> std::same_as<void>;
26 { a.registerWriteSync(std::chrono::steady_clock::time_point{}) } -> std::same_as<void>;
27 { a.registerWriteSyncRetry() } -> std::same_as<void>;
28 { a.registerWriteStarted() } -> std::same_as<void>;
29 { a.registerWriteFinished(std::chrono::steady_clock::time_point{}) } -> std::same_as<void>;
30 { a.registerWriteRetry() } -> std::same_as<void>;
31 { a.registerReadStarted(std::uint64_t{}) } -> std::same_as<void>;
33 a.registerReadFinished(std::chrono::steady_clock::time_point{}, std::uint64_t{})
34 } -> std::same_as<void>;
35 { a.registerReadRetry(std::uint64_t{}) } -> std::same_as<void>;
36 { a.registerReadError(std::uint64_t{}) } -> std::same_as<void>;
37 { a.report() } -> std::same_as<boost::json::object>;
45class BackendCounters {
50 using PtrType = std::shared_ptr<BackendCounters>;
115 registerReadFinished(std::chrono::steady_clock::time_point startTime, std::uint64_t count = 1u);
138 [[nodiscard]] boost::json::object
144 class AsyncOperationCounters {
146 AsyncOperationCounters(std::string name);
149 registerStarted(std::uint64_t count);
152 registerFinished(std::uint64_t count);
155 registerRetry(std::uint64_t count);
158 registerError(std::uint64_t count);
160 [[nodiscard]] boost::json::object
165 std::reference_wrapper<util::prometheus::GaugeInt> pendingCounter_;
166 std::reference_wrapper<util::prometheus::CounterInt> completedCounter_;
167 std::reference_wrapper<util::prometheus::CounterInt> retryCounter_;
168 std::reference_wrapper<util::prometheus::CounterInt> errorCounter_;
171 std::reference_wrapper<util::prometheus::CounterInt> tooBusyCounter_;
173 std::reference_wrapper<util::prometheus::CounterInt> writeSyncCounter_;
174 std::reference_wrapper<util::prometheus::CounterInt> writeSyncRetryCounter_;
176 AsyncOperationCounters asyncWriteCounters_{
"write_async"};
177 AsyncOperationCounters asyncReadCounters_{
"read_async"};
179 std::reference_wrapper<util::prometheus::HistogramInt> readDurationHistogram_;
180 std::reference_wrapper<util::prometheus::HistogramInt> writeDurationHistogram_;
void registerTooBusy()
Register that the backend was too busy to process a request.
Definition BackendCounters.cpp:86
void registerWriteRetry()
Register that a write operation was retried.
Definition BackendCounters.cpp:119
void registerReadStarted(std::uint64_t count=1u)
Register that one or more read operations were started.
Definition BackendCounters.cpp:125
boost::json::object report() const
Get a report of the backend counters.
Definition BackendCounters.cpp:155
void registerWriteFinished(std::chrono::steady_clock::time_point startTime)
Register that a write operation was finished.
Definition BackendCounters.cpp:111
void registerWriteStarted()
Register that a write operation was started.
Definition BackendCounters.cpp:105
void registerWriteSync(std::chrono::steady_clock::time_point startTime)
Register that a write operation was started.
Definition BackendCounters.cpp:92
void registerReadFinished(std::chrono::steady_clock::time_point startTime, std::uint64_t count=1u)
Register that one or more read operations were finished.
Definition BackendCounters.cpp:131
void registerReadRetry(std::uint64_t count=1u)
Register that one or more read operations were retried.
Definition BackendCounters.cpp:143
std::shared_ptr< BackendCounters > PtrType
Shared pointer type used to hold BackendCounters instances.
Definition BackendCounters.hpp:50
void registerWriteSyncRetry()
Register that a write operation was retried.
Definition BackendCounters.cpp:99
static PtrType make()
Create a new BackendCounters object.
Definition BackendCounters.cpp:79
void registerReadError(std::uint64_t count=1u)
Register that one or more read operations had an error.
Definition BackendCounters.cpp:149
A concept for a class that can be used to count backend operations.
Definition BackendCounters.hpp:23
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:56