Module agora.stats.Collector

Contains methods that collect stats from primitive data members of structs or classes to respond to Prometheus queries with.

The metric designs specified by Prometheus (https://prometheus.io/docs/concepts/metric_types/) have not been implemented yet. So, as of now, this collector can process only primitive data-type members from a struct or a class. However, the current Prometheus stat collection framework could be enhanced to support metrics with a very little effort.

In Prometheus' data model, the stats that are measured are called Metrics, and the dimensions along which stats are measured are called Labels.

Metrics can be any measurable value, e.g., CPU or memory consumption.

Labels resemble key-value pairs, where the key is referred to as a label's name, and the value as a label's value. A label name would refer to the name of a dimension across which we want to measure stats. Correspondingly, a label value would refer to a point along the said dimension. A stat can have more than one label, if it is intended to be measured across multiple dimensions.

Stats with labels look like the following example ` promhttp_metric_handler_requests_total{code="200"} 3 promhttp_metric_handler_requests_total{code="500"} 0 promhttp_metric_handler_requests_total{code="503"} 0 ` Here promhttp_metric_handler_requests_total is the metric, code is the label name, "200", "500" and "503" are the label values, and 3, 0 and 0 are the respective metric values.

On the data visualization side of Prometheus, fetching stats using queries is analogous to calling functions. A metric name is analogous to a function name, and a label is analogous to a function parameter. Continuing with the above example, the following query will return 3: ` promhttp_metric_handler_requests_total {code="200"} `

(For detailed information about Prometheus-specific terminology, e.g., Metrics and Labels, please refer to https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels.)

This module contains a class which can be used to collect metrics as well as labels from composite-type values, and format them in a way acceptable for Prometheus.

Classes

NameDescription
Collector This class provides methods to collect metrics with no label, one label, or multiple labels, using overloaded definitions of the collect method.