LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
logit::PrometheusRegistry Class Reference

Stores custom gauge and counter callbacks for Prometheus collection. More...

#include <PrometheusRegistry.hpp>

Classes

struct  Entry
 

Public Member Functions

 PrometheusRegistry (std::string metric_prefix=std::string())
 Constructs registry with an optional metric prefix.
 
void set_metric_prefix (const std::string &metric_prefix)
 Sets prefix applied to metrics collected by this registry.
 
const std::string & metric_prefix () const
 Returns prefix applied to metrics collected by this registry.
 
void set_gauge (const std::string &name, const std::string &help, std::function< double()> value_fn, std::vector< PrometheusLabel > labels={})
 Registers or replaces a gauge metric callback.
 
void set_counter (const std::string &name, const std::string &help, std::function< double()> value_fn, std::vector< PrometheusLabel > labels={})
 Registers or replaces a counter metric callback.
 
void collect (std::vector< PrometheusMetricFamily > &out) const
 Appends current registry metrics to the output vector.
 

Private Member Functions

void set_metric (PrometheusMetricType type, const std::string &name, const std::string &help, std::function< double()> value_fn, std::vector< PrometheusLabel > labels)
 

Static Private Member Functions

static bool labels_equal (const std::vector< PrometheusLabel > &lhs, const std::vector< PrometheusLabel > &rhs)
 
static PrometheusMetricFamily * find_family (std::vector< PrometheusMetricFamily > &families, const std::string &name, PrometheusMetricType type)
 

Private Attributes

std::string m_metric_prefix
 
std::vector< Entry > m_entries
 

Detailed Description

Stores custom gauge and counter callbacks for Prometheus collection.

Definition at line 21 of file PrometheusRegistry.hpp.

Constructor & Destructor Documentation

◆ PrometheusRegistry()

logit::PrometheusRegistry::PrometheusRegistry ( std::string metric_prefix = std::string())
inlineexplicit

Constructs registry with an optional metric prefix.

Definition at line 24 of file PrometheusRegistry.hpp.

Member Function Documentation

◆ collect()

void logit::PrometheusRegistry::collect ( std::vector< PrometheusMetricFamily > & out) const
inline

Appends current registry metrics to the output vector.

Definition at line 66 of file PrometheusRegistry.hpp.

◆ find_family()

static PrometheusMetricFamily * logit::PrometheusRegistry::find_family ( std::vector< PrometheusMetricFamily > & families,
const std::string & name,
PrometheusMetricType type )
inlinestaticprivate

Definition at line 160 of file PrometheusRegistry.hpp.

◆ labels_equal()

static bool logit::PrometheusRegistry::labels_equal ( const std::vector< PrometheusLabel > & lhs,
const std::vector< PrometheusLabel > & rhs )
inlinestaticprivate

Definition at line 146 of file PrometheusRegistry.hpp.

◆ metric_prefix()

const std::string & logit::PrometheusRegistry::metric_prefix ( ) const
inline

Returns prefix applied to metrics collected by this registry.

Definition at line 33 of file PrometheusRegistry.hpp.

◆ set_counter()

void logit::PrometheusRegistry::set_counter ( const std::string & name,
const std::string & help,
std::function< double()> value_fn,
std::vector< PrometheusLabel > labels = {} )
inline

Registers or replaces a counter metric callback.

Definition at line 52 of file PrometheusRegistry.hpp.

◆ set_gauge()

void logit::PrometheusRegistry::set_gauge ( const std::string & name,
const std::string & help,
std::function< double()> value_fn,
std::vector< PrometheusLabel > labels = {} )
inline

Registers or replaces a gauge metric callback.

Definition at line 38 of file PrometheusRegistry.hpp.

◆ set_metric()

void logit::PrometheusRegistry::set_metric ( PrometheusMetricType type,
const std::string & name,
const std::string & help,
std::function< double()> value_fn,
std::vector< PrometheusLabel > labels )
inlineprivate

Definition at line 120 of file PrometheusRegistry.hpp.

◆ set_metric_prefix()

void logit::PrometheusRegistry::set_metric_prefix ( const std::string & metric_prefix)
inline

Sets prefix applied to metrics collected by this registry.

Definition at line 28 of file PrometheusRegistry.hpp.

Member Data Documentation

◆ m_entries

std::vector<Entry> logit::PrometheusRegistry::m_entries
private

Definition at line 118 of file PrometheusRegistry.hpp.

◆ m_metric_prefix

std::string logit::PrometheusRegistry::m_metric_prefix
private

Definition at line 117 of file PrometheusRegistry.hpp.


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