refactor: Load balancer forwarding metrics (#2103)

This commit is contained in:
Ayaz Salikhov
2025-05-14 11:43:31 +01:00
committed by GitHub
parent a369381594
commit 243e174f1e
3 changed files with 111 additions and 37 deletions

View File

@@ -33,7 +33,6 @@
#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>
@@ -94,10 +93,13 @@ private:
std::uint32_t downloadRanges_ =
kDEFAULT_DOWNLOAD_RANGES; /*< The number of markers to use when downloading initial ledger */
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_;
struct ForwardingCounters {
std::reference_wrapper<util::prometheus::CounterInt> successDuration;
std::reference_wrapper<util::prometheus::CounterInt> failDuration;
std::reference_wrapper<util::prometheus::CounterInt> retries;
std::reference_wrapper<util::prometheus::CounterInt> cacheHit;
std::reference_wrapper<util::prometheus::CounterInt> cacheMiss;
} forwardingCounters_;
// 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