C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::telemetry::metric_registry Class Reference

Manages a collection of metric families. More...

#include <metric_registry.hpp>

Classes

struct  span_type
 Forces the compiler to use the type span<const T> instead of trying to match parameters to a span. More...
 

Public Types

template<class T >
using span_t = typename span_type<T>::type
 Convenience alias to safe some typing.
 

Public Member Functions

 metric_registry (const actor_system_config &cfg)
 
template<class ValueType = int64_t>
metric_family_impl< gauge< ValueType > > * gauge_family (std::string_view prefix, std::string_view name, span_t< std::string_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a gauge metric family.
 
template<class ValueType = int64_t>
metric_family_impl< gauge< ValueType > > * gauge_family (std::string_view prefix, std::string_view name, std::initializer_list< std::string_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a gauge metric family.
 
template<class ValueType = int64_t>
metric_family_impl< gauge< ValueType > > * gauge_family (std::string_view prefix, std::string_view name, span_t< label_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a gauge metric family.
 
template<class ValueType = int64_t>
gauge< ValueType > * gauge_instance (std::string_view prefix, std::string_view name, span_t< label_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a gauge.
 
template<class ValueType = int64_t>
gauge< ValueType > * gauge_instance (std::string_view prefix, std::string_view name, std::initializer_list< label_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a gauge.
 
template<class ValueType = int64_t>
gauge< ValueType > * gauge_singleton (std::string_view prefix, std::string_view name, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a gauge metric singleton, i.e., the single instance of a family without label dimensions.
 
template<class ValueType = int64_t>
metric_family_impl< counter< ValueType > > * counter_family (std::string_view prefix, std::string_view name, span_t< std::string_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a counter metric family.
 
template<class ValueType = int64_t>
metric_family_impl< counter< ValueType > > * counter_family (std::string_view prefix, std::string_view name, std::initializer_list< std::string_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a counter metric family.
 
template<class ValueType = int64_t>
counter< ValueType > * counter_instance (std::string_view prefix, std::string_view name, span_t< label_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a counter.
 
template<class ValueType = int64_t>
counter< ValueType > * counter_instance (std::string_view prefix, std::string_view name, std::initializer_list< label_view > labels, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a counter.
 
template<class ValueType = int64_t>
counter< ValueType > * counter_singleton (std::string_view prefix, std::string_view name, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a counter metric singleton, i.e., the single instance of a family without label dimensions.
 
template<class ValueType = int64_t>
metric_family_impl< histogram< ValueType > > * histogram_family (std::string_view prefix, std::string_view name, span_t< std::string_view > label_names, span_t< ValueType > default_upper_bounds, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a histogram metric family.
 
template<class ValueType = int64_t>
metric_family_impl< histogram< ValueType > > * histogram_family (std::string_view prefix, std::string_view name, std::initializer_list< std::string_view > label_names, span_t< ValueType > upper_bounds, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a gauge metric family.
 
template<class ValueType = int64_t>
histogram< ValueType > * histogram_instance (std::string_view prefix, std::string_view name, span_t< label_view > labels, span_t< ValueType > upper_bounds, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a histogram.
 
template<class ValueType = int64_t>
histogram< ValueType > * histogram_instance (std::string_view prefix, std::string_view name, std::initializer_list< label_view > labels, span_t< ValueType > upper_bounds, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 @copdoc histogram_instance
 
template<class ValueType = int64_t>
histogram< ValueType > * histogram_singleton (std::string_view prefix, std::string_view name, span_t< ValueType > upper_bounds, std::string_view helptext, std::string_view unit="1", bool is_sum=false)
 Returns a histogram metric singleton, i.e., the single instance of a family without label dimensions.
 
void config (const settings *ptr)
 
template<class Collector >
void collect (Collector &collector) const
 
void merge (metric_registry &other)
 Takes ownership of all metric families in other.
 

Static Public Member Functions

static metric_registryfrom (actor_system &sys)
 Returns a pointer to the metric registry from the actor system.
 

Detailed Description

Manages a collection of metric families.

Member Function Documentation

◆ counter_family() [1/2]

template<class ValueType = int64_t>
metric_family_impl< counter< ValueType > > * caf::telemetry::metric_registry::counter_family ( std::string_view prefix,
std::string_view name,
span_t< std::string_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a counter metric family.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsNames for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ counter_family() [2/2]

template<class ValueType = int64_t>
metric_family_impl< counter< ValueType > > * caf::telemetry::metric_registry::counter_family ( std::string_view prefix,
std::string_view name,
std::initializer_list< std::string_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a counter metric family.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsNames for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ counter_instance() [1/2]

template<class ValueType = int64_t>
counter< ValueType > * caf::telemetry::metric_registry::counter_instance ( std::string_view prefix,
std::string_view name,
span_t< label_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a counter.

Creates all objects lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsValues for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ counter_instance() [2/2]

template<class ValueType = int64_t>
counter< ValueType > * caf::telemetry::metric_registry::counter_instance ( std::string_view prefix,
std::string_view name,
std::initializer_list< label_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a counter.

Creates all objects lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsValues for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ counter_singleton()

template<class ValueType = int64_t>
counter< ValueType > * caf::telemetry::metric_registry::counter_singleton ( std::string_view prefix,
std::string_view name,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a counter metric singleton, i.e., the single instance of a family without label dimensions.

Creates all objects lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ gauge_family() [1/3]

template<class ValueType = int64_t>
metric_family_impl< gauge< ValueType > > * caf::telemetry::metric_registry::gauge_family ( std::string_view prefix,
std::string_view name,
span_t< label_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a gauge metric family.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsNames for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ gauge_family() [2/3]

template<class ValueType = int64_t>
metric_family_impl< gauge< ValueType > > * caf::telemetry::metric_registry::gauge_family ( std::string_view prefix,
std::string_view name,
span_t< std::string_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a gauge metric family.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsNames for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ gauge_family() [3/3]

template<class ValueType = int64_t>
metric_family_impl< gauge< ValueType > > * caf::telemetry::metric_registry::gauge_family ( std::string_view prefix,
std::string_view name,
std::initializer_list< std::string_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a gauge metric family.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsNames for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ gauge_instance() [1/2]

template<class ValueType = int64_t>
gauge< ValueType > * caf::telemetry::metric_registry::gauge_instance ( std::string_view prefix,
std::string_view name,
span_t< label_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a gauge.

Creates all objects lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsValues for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ gauge_instance() [2/2]

template<class ValueType = int64_t>
gauge< ValueType > * caf::telemetry::metric_registry::gauge_instance ( std::string_view prefix,
std::string_view name,
std::initializer_list< label_view > labels,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a gauge.

Creates all objects lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsValues for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ gauge_singleton()

template<class ValueType = int64_t>
gauge< ValueType > * caf::telemetry::metric_registry::gauge_singleton ( std::string_view prefix,
std::string_view name,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a gauge metric singleton, i.e., the single instance of a family without label dimensions.

Creates all objects lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ histogram_family() [1/2]

template<class ValueType = int64_t>
metric_family_impl< histogram< ValueType > > * caf::telemetry::metric_registry::histogram_family ( std::string_view prefix,
std::string_view name,
span_t< std::string_view > label_names,
span_t< ValueType > default_upper_bounds,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a histogram metric family.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
label_namesNames for all label dimensions of the metric.
default_upper_boundsUpper bounds for the metric buckets.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.
Note
The first call wins when calling this function multiple times with different bucket settings. Later calls skip checking the bucket settings, mainly because this check would be rather expensive.
The actor system config may override upper_bounds.

◆ histogram_family() [2/2]

template<class ValueType = int64_t>
metric_family_impl< histogram< ValueType > > * caf::telemetry::metric_registry::histogram_family ( std::string_view prefix,
std::string_view name,
std::initializer_list< std::string_view > label_names,
span_t< ValueType > upper_bounds,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a gauge metric family.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsNames for all label dimensions of the metric.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.

◆ histogram_instance()

template<class ValueType = int64_t>
histogram< ValueType > * caf::telemetry::metric_registry::histogram_instance ( std::string_view prefix,
std::string_view name,
span_t< label_view > labels,
span_t< ValueType > upper_bounds,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a histogram.

Creates the family lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
labelsNames for all label dimensions of the metric.
upper_boundsUpper bounds for the metric buckets.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such asbytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.
Note
The first call wins when calling this function multiple times with different bucket settings. Later calls skip checking the bucket settings, mainly because this check would be rather expensive.
The actor system config may override upper_bounds.

◆ histogram_singleton()

template<class ValueType = int64_t>
histogram< ValueType > * caf::telemetry::metric_registry::histogram_singleton ( std::string_view prefix,
std::string_view name,
span_t< ValueType > upper_bounds,
std::string_view helptext,
std::string_view unit = "1",
bool is_sum = false )

Returns a histogram metric singleton, i.e., the single instance of a family without label dimensions.

Creates all objects lazily if necessary, but fails if the full name already belongs to a different family.

Parameters
prefixThe prefix (namespace) this family belongs to. Usually the application or protocol name, e.g., http. The prefix caf as well as prefixes starting with an underscore are reserved.
nameThe human-readable name of the metric, e.g., requests.
helptextShort explanation of the metric.
unitUnit of measurement. Please use base units such as bytes or seconds (prefer lowercase). The pseudo-unit 1 identifies dimensionless counts.
is_sumSetting this to true indicates that this metric adds something up to a total, where only the total value is of interest. For example, the total number of HTTP requests.
Note
The actor system config may override upper_bounds.

◆ merge()

void caf::telemetry::metric_registry::merge ( metric_registry & other)

Takes ownership of all metric families in other.

Precondition
other must not contain any duplicated metric family

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