Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::prometheus::PrometheusImpl Class Reference

Implemetation of PrometheusInterface. More...

#include <Prometheus.hpp>

Inheritance diagram for util::prometheus::PrometheusImpl:
Collaboration diagram for util::prometheus::PrometheusImpl:

Public Member Functions

Bool boolMetric (std::string name, Labels labels, std::optional< std::string > description=std::nullopt) override
 Get a bool based metric. It will be created if it doesn't exist.
 
CounterIntcounterInt (std::string name, Labels labels, std::optional< std::string > description) override
 Get an integer based counter metric. It will be created if it doesn't exist.
 
CounterDoublecounterDouble (std::string name, Labels labels, std::optional< std::string > description) override
 Get a double based counter metric. It will be created if it doesn't exist.
 
GaugeIntgaugeInt (std::string name, Labels labels, std::optional< std::string > description) override
 Get an integer based gauge metric. It will be created if it doesn't exist.
 
GaugeDoublegaugeDouble (std::string name, Labels labels, std::optional< std::string > description) override
 Get a double based gauge metric. It will be created if it doesn't exist.
 
HistogramInthistogramInt (std::string name, Labels labels, std::vector< std::int64_t > const &buckets, std::optional< std::string > description=std::nullopt) override
 Get an integer based histogram metric. It will be created if it doesn't exist.
 
HistogramDoublehistogramDouble (std::string name, Labels labels, std::vector< double > const &buckets, std::optional< std::string > description=std::nullopt) override
 Get a double based histogram metric. It will be created if it doesn't exist.
 
std::string collectMetrics () override
 Collect all metrics and return them as a string in Prometheus format.
 
 PrometheusInterface (bool isEnabled, bool compressReply)
 Construct a new Prometheus Interface object.
 
- Public Member Functions inherited from util::prometheus::PrometheusInterface
 PrometheusInterface (bool isEnabled, bool compressReply)
 Construct a new Prometheus Interface object.
 
bool isEnabled () const
 Whether prometheus is enabled.
 
bool compressReplyEnabled () const
 Whether to compress the reply.
 

Detailed Description

Implemetation of PrometheusInterface.

Note
When prometheus is disabled, all metrics will still counted but collection is disabled

Member Function Documentation

◆ boolMetric()

Bool util::prometheus::PrometheusImpl::boolMetric ( std::string name,
Labels labels,
std::optional< std::string > description = std::nullopt )
overridevirtual

Get a bool based metric. It will be created if it doesn't exist.

Note
Prometheus does not have a native bool type, so we use a counter with a value of 0 or 1
Parameters
nameThe name of the metric
labelsThe labels of the metric
descriptionThe description of the metric
Returns
The bool object

Implements util::prometheus::PrometheusInterface.

◆ collectMetrics()

std::string util::prometheus::PrometheusImpl::collectMetrics ( )
overridevirtual

Collect all metrics and return them as a string in Prometheus format.

Returns
The serialized metrics

Implements util::prometheus::PrometheusInterface.

◆ counterDouble()

CounterDouble & util::prometheus::PrometheusImpl::counterDouble ( std::string name,
Labels labels,
std::optional< std::string > description )
overridevirtual

Get a double based counter metric. It will be created if it doesn't exist.

Parameters
nameThe name of the metric
labelsThe labels of the metric
descriptionThe description of the metric
Returns
A reference to the counter object

Implements util::prometheus::PrometheusInterface.

◆ counterInt()

CounterInt & util::prometheus::PrometheusImpl::counterInt ( std::string name,
Labels labels,
std::optional< std::string > description )
overridevirtual

Get an integer based counter metric. It will be created if it doesn't exist.

Parameters
nameThe name of the metric
labelsThe labels of the metric
descriptionThe description of the metric
Returns
A reference to the counter object

Implements util::prometheus::PrometheusInterface.

◆ gaugeDouble()

GaugeDouble & util::prometheus::PrometheusImpl::gaugeDouble ( std::string name,
Labels labels,
std::optional< std::string > description )
overridevirtual

Get a double based gauge metric. It will be created if it doesn't exist.

Parameters
nameThe name of the metric
labelsThe labels of the metric
descriptionThe description of the metric
Returns
A reference to the gauge object

Implements util::prometheus::PrometheusInterface.

◆ gaugeInt()

GaugeInt & util::prometheus::PrometheusImpl::gaugeInt ( std::string name,
Labels labels,
std::optional< std::string > description )
overridevirtual

Get an integer based gauge metric. It will be created if it doesn't exist.

Parameters
nameThe name of the metric
labelsThe labels of the metric
descriptionThe description of the metric
Returns
A reference to the gauge object

Implements util::prometheus::PrometheusInterface.

◆ histogramDouble()

HistogramDouble & util::prometheus::PrometheusImpl::histogramDouble ( std::string name,
Labels labels,
std::vector< double > const & buckets,
std::optional< std::string > description = std::nullopt )
overridevirtual

Get a double based histogram metric. It will be created if it doesn't exist.

Parameters
nameThe name of the metric
labelsThe labels of the metric
bucketsThe buckets of the metric
descriptionThe description of the metric
Returns
A reference to the histogram object

Implements util::prometheus::PrometheusInterface.

◆ histogramInt()

HistogramInt & util::prometheus::PrometheusImpl::histogramInt ( std::string name,
Labels labels,
std::vector< std::int64_t > const & buckets,
std::optional< std::string > description = std::nullopt )
overridevirtual

Get an integer based histogram metric. It will be created if it doesn't exist.

Parameters
nameThe name of the metric
labelsThe labels of the metric
bucketsThe buckets of the metric
descriptionThe description of the metric
Returns
A reference to the histogram object

Implements util::prometheus::PrometheusInterface.

◆ PrometheusInterface()

util::prometheus::PrometheusInterface::PrometheusInterface ( bool isEnabled,
bool compressReply )
inline

Construct a new Prometheus Interface object.

Parameters
isEnabledWhether prometheus is enabled
compressReplyWhether to compress the reply

The documentation for this class was generated from the following files: