Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Metrics.hpp
1#pragma once
2
3#include "cluster/Backend.hpp"
4#include "cluster/ClioNode.hpp"
5#include "util/prometheus/Bool.hpp"
6#include "util/prometheus/Gauge.hpp"
7#include "util/prometheus/Prometheus.hpp"
8
9#include <memory>
10
11namespace cluster {
12
20class Metrics {
22 util::prometheus::GaugeInt& nodesInClusterMetric_ = PrometheusService::gaugeInt(
23 "cluster_nodes_total_number",
24 {},
25 "Total number of nodes this node can detect in the cluster."
26 );
27
29 util::prometheus::Bool isHealthy_ = PrometheusService::boolMetric(
30 "cluster_communication_is_healthy",
31 {},
32 "Whether cluster communication service is operating healthy (1 - healthy, 0 - we have a "
33 "problem)"
34 );
35
36public:
42 Metrics();
43
55 void
56 onNewState(ClioNode::CUuid uuid, std::shared_ptr<Backend::ClusterData const> clusterData);
57};
58
59} // namespace cluster
static util::prometheus::Bool boolMetric(std::string name, util::prometheus::Labels labels, std::optional< std::string > description=std::nullopt)
Get a bool based metric. It will be created if it doesn't exist.
Definition Prometheus.cpp:201
static util::prometheus::GaugeInt & gaugeInt(std::string name, util::prometheus::Labels labels, std::optional< std::string > description=std::nullopt)
Get an integer based gauge metric. It will be created if it doesn't exist.
Definition Prometheus.cpp:231
Metrics()
Constructs a Metrics instance and initializes metrics.
Definition Metrics.cpp:10
void onNewState(ClioNode::CUuid uuid, std::shared_ptr< Backend::ClusterData const > clusterData)
Updates metrics based on new cluster state.
Definition Metrics.cpp:17