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 {
24 util::prometheus::GaugeInt& nodesInClusterMetric_ = PrometheusService::gaugeInt(
25 "cluster_nodes_total_number",
26 {},
27 "Total number of nodes this node can detect in the cluster."
28 );
29
33 util::prometheus::Bool isHealthy_ = PrometheusService::boolMetric(
34 "cluster_communication_is_healthy",
35 {},
36 "Whether cluster communication service is operating healthy (1 - healthy, 0 - we have a "
37 "problem)"
38 );
39
40public:
46 Metrics();
47
59 void
60 onNewState(ClioNode::CUuid uuid, std::shared_ptr<Backend::ClusterData const> clusterData);
61};
62
63} // 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