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

Class representing a collection of Prometheus metric with the same name and type. More...

#include <MetricsFamily.hpp>

Public Member Functions

 MetricsFamily (std::string name, std::optional< std::string > description, MetricType type, MetricBuilderInterface &builder= *defaultMetricBuilder)
 Construct a new MetricsFamily object.
 
 MetricsFamily (MetricsFamily const &)=delete
 
 MetricsFamily (MetricsFamily &&)=default
 
MetricsFamilyoperator= (MetricsFamily const &)=delete
 
MetricsFamilyoperator= (MetricsFamily &&)=delete
 
MetricBasegetMetric (Labels labels, std::vector< std::int64_t > const &buckets={})
 Get the metric with the given labels. If it does not exist, it will be created.
 
MetricBasegetMetric (Labels labels, std::vector< double > const &buckets)
 Get the metric with the given labels. If it does not exist, it will be created.
 
std::string const & name () const
 Get the name of the metrics.
 
MetricType type () const
 Get the description of the metrics.
 

Static Public Attributes

static std::unique_ptr< MetricBuilderInterfacedefaultMetricBuilder = std::make_unique<MetricBuilder>()
 

Friends

OStreamoperator<< (OStream &stream, MetricsFamily const &metricsFamily)
 Serialize the metrics to a string in Prometheus format as one block.
 

Detailed Description

Class representing a collection of Prometheus metric with the same name and type.

Constructor & Destructor Documentation

◆ MetricsFamily()

util::prometheus::MetricsFamily::MetricsFamily ( std::string name,
std::optional< std::string > description,
MetricType type,
MetricBuilderInterface & builder = *defaultMetricBuilder )

Construct a new MetricsFamily object.

Parameters
nameThe name of the metrics
descriptionThe description of the metrics
typeThe type of the metrics
builderThe metric builder to use

Member Function Documentation

◆ getMetric() [1/2]

MetricBase & util::prometheus::MetricsFamily::getMetric ( Labels labels,
std::vector< double > const & buckets )

Get the metric with the given labels. If it does not exist, it will be created.

Note
This overload is only used for histograms with integer buckets
Parameters
labelsThe labels of the metric
bucketsThe buckets of the histogram. It is ignored for other metric types or if the metric already exists
Returns
Reference to the metric

◆ getMetric() [2/2]

MetricBase & util::prometheus::MetricsFamily::getMetric ( Labels labels,
std::vector< std::int64_t > const & buckets = {} )

Get the metric with the given labels. If it does not exist, it will be created.

Parameters
labelsThe labels of the metric
bucketsThe buckets of the histogram. It is ignored for other metric types or if the metric already exists
Returns
Reference to the metric

◆ name()

std::string const & util::prometheus::MetricsFamily::name ( ) const

Get the name of the metrics.

Returns
The name

◆ type()

MetricType util::prometheus::MetricsFamily::type ( ) const

Get the description of the metrics.

Returns
The description

Friends And Related Symbol Documentation

◆ operator<<

OStream & operator<< ( OStream & stream,
MetricsFamily const & metricsFamily )
friend

Serialize the metrics to a string in Prometheus format as one block.

Parameters
streamThe stream to serialize into
metricsFamilyThe metrics to serialize

Member Data Documentation

◆ defaultMetricBuilder

std::unique_ptr< MetricBuilderInterface > util::prometheus::MetricsFamily::defaultMetricBuilder = std::make_unique<MetricBuilder>()
static

The default metric builder


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