feat: Add load balancer prometheus metrics (#2096)

Fix: https://github.com/XRPLF/clio/issues/2070
This commit is contained in:
Ayaz Salikhov
2025-05-12 14:15:22 +01:00
committed by GitHub
parent ce41f5ba07
commit dbfabd4102
3 changed files with 47 additions and 11 deletions

View File

@@ -32,6 +32,8 @@
#include "util/ResponseExpirationCache.hpp"
#include "util/log/Logger.hpp"
#include "util/newconfig/ConfigDefinition.hpp"
#include "util/prometheus/Counter.hpp"
#include "util/prometheus/Histogram.hpp"
#include <boost/asio.hpp>
#include <boost/asio/io_context.hpp>
@@ -92,7 +94,12 @@ private:
std::uint32_t downloadRanges_ =
kDEFAULT_DOWNLOAD_RANGES; /*< The number of markers to use when downloading initial ledger */
// Using mutext instead of atomic_bool because choosing a new source to
std::reference_wrapper<util::prometheus::HistogramInt> forwardedDurationHistogram_;
std::reference_wrapper<util::prometheus::CounterInt> forwardedRetryCounter_;
std::reference_wrapper<util::prometheus::CounterInt> cacheTriedCounter_;
std::reference_wrapper<util::prometheus::CounterInt> cacheMissCounter_;
// Using mutex instead of atomic_bool because choosing a new source to
// forward messages should be done with a mutual exclusion otherwise there will be a race condition
util::Mutex<bool> hasForwardingSource_{false};
@@ -133,7 +140,7 @@ public:
* @param ioc The io_context to run on
* @param backend BackendInterface implementation
* @param subscriptions Subscription manager
* @param validatedLedgers The network validated ledgers datastructure
* @param validatedLedgers The network validated ledgers data structure
* @param sourceFactory A factory function to create a source
* @return A shared pointer to a new instance of LoadBalancer
*/
@@ -147,8 +154,6 @@ public:
SourceFactory sourceFactory = makeSource
);
~LoadBalancer() override;
/**
* @brief Load the initial ledger, writing data to the queue.
* @note This function will retry indefinitely until the ledger is downloaded.