Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
An actual, honest to god, metric. More...
#include <res_prometheus.h>
Data Fields | |
enum prometheus_metric_allocation_strategy | allocation_strategy |
How this metric was allocated. More... | |
struct { | |
struct prometheus_metric * first | |
struct prometheus_metric * last | |
} | children |
A list of children metrics. More... | |
struct { | |
struct prometheus_metric * next | |
} | entry |
void(* | get_metric_value )(struct prometheus_metric *metric) |
Callback function to obtain the metric value. More... | |
const char * | help |
Pointer to a static string defining this metric's help text. More... | |
struct prometheus_label | labels [PROMETHEUS_MAX_LABELS] |
The metric's labels. More... | |
ast_mutex_t | lock |
A lock protecting the metric value . More... | |
char | name [PROMETHEUS_MAX_NAME_LENGTH] |
Our metric name. More... | |
enum prometheus_metric_type | type |
What type of metric we are. More... | |
char | value [PROMETHEUS_MAX_VALUE_LENGTH] |
The current value. More... | |
An actual, honest to god, metric.
A bit of effort has gone into making this structure as efficient as we possibly can. Given that a lot of metrics can theoretically be dumped out, and that Asterisk attempts to be a "real-time" system, we want this process to be as efficient as possible. Countering that is the ridiculous flexibility that Prometheus allows for (and, to an extent, wants) - namely the notion of families of metrics delineated by their labels.
In order to balance this, metrics have arrays of labels. While this makes for a very large struct (such that loading one of these into memory is probably going to blow your cache), you will at least get the whole thing, since you're going to need those labels to figure out what you're looking like.
A hierarchy of metrics occurs when all metrics have the same name
, but different labels.
We manage the hierarchy by allowing a metric to maintain their own list of related metrics. When metrics are registered (/c prometheus_metric_register), the function will automatically determine the hierarchy and place them into the appropriate lists. When you are creating metrics on the fly in a callback (prometheus_callback_register
), you have to manage this hierarchy yourself, and only print out the first metric in a chain.
Note that EVERYTHING in a metric is immutable once registered, save for its value. Modifying the hierarchy, labels, name, help, whatever is going to result in a "bad time", and is also expressly against Prometheus law. (Don't get your liver eaten.)
Definition at line 193 of file res_prometheus.h.
enum prometheus_metric_allocation_strategy allocation_strategy |
How this metric was allocated.
Definition at line 201 of file res_prometheus.h.
Referenced by prometheus_metric_create(), and prometheus_metric_free().
struct { ... } children |
A list of children metrics.
Children metrics have the same name but different label.
Registration of a metric will automatically nest the metrics; otherwise they are treated independently.
The help of the first metric in a chain of related metrics is the only one that will be printed.
For metrics output during a callback, the handler is responsible for managing the children. For metrics that are registered, the registration automatically nests the metrics.
Referenced by AST_TEST_DEFINE(), channels_scrape_cb(), prometheus_metric_free(), prometheus_metric_register(), prometheus_metric_to_string(), and prometheus_metric_unregister().
struct { ... } entry |
struct prometheus_metric* first |
Definition at line 249 of file res_prometheus.h.
void(* get_metric_value) (struct prometheus_metric *metric) |
Callback function to obtain the metric value.
If updates need to happen when the metric is gathered, provide the callback function. Otherwise, leave it NULL
.
Definition at line 233 of file res_prometheus.h.
Referenced by channels_scrape_cb(), and scrape_metrics().
const char* help |
Pointer to a static string defining this metric's help text.
Definition at line 211 of file res_prometheus.h.
Referenced by channels_scrape_cb(), endpoints_scrape_cb(), prometheus_counter_create(), prometheus_gauge_create(), prometheus_metric_create(), and prometheus_metric_to_string().
struct prometheus_label labels[PROMETHEUS_MAX_LABELS] |
The metric's labels.
Definition at line 219 of file res_prometheus.h.
Referenced by prometheus_metric_cmp(), and prometheus_metric_full_to_string().
struct prometheus_metric* last |
Definition at line 249 of file res_prometheus.h.
ast_mutex_t lock |
A lock protecting the metric value
.
Definition at line 207 of file res_prometheus.h.
Referenced by prometheus_metric_create(), prometheus_metric_free(), and scrape_metrics().
char name[PROMETHEUS_MAX_NAME_LENGTH] |
Our metric name.
Definition at line 215 of file res_prometheus.h.
Referenced by PathSegment::get_child(), Parameter::load(), Property::load(), SwaggerType::load(), prometheus_metric_cmp(), prometheus_metric_create(), prometheus_metric_full_to_string(), prometheus_metric_register(), prometheus_metric_to_string(), and prometheus_metric_unregister().
struct prometheus_metric* next |
Definition at line 250 of file res_prometheus.h.
enum prometheus_metric_type type |
What type of metric we are.
Definition at line 197 of file res_prometheus.h.
Referenced by channels_scrape_cb(), endpoints_scrape_cb(), Property::load(), prometheus_counter_create(), prometheus_gauge_create(), and prometheus_metric_to_string().
char value[PROMETHEUS_MAX_VALUE_LENGTH] |
The current value.
If get_metric_value
is set, this value is ignored until the callback happens
Definition at line 226 of file res_prometheus.h.
Referenced by AST_TEST_DEFINE(), bridges_scrape_cb(), channels_scrape_cb(), endpoints_scrape_cb(), get_bridge_channel_count(), get_channel_duration(), get_channel_state(), get_core_uptime_cb(), get_current_call_count(), get_endpoint_channel_count(), get_endpoint_state(), get_last_reload_cb(), get_total_call_count(), http_callback(), metric_values_get_counter_value_cb(), prometheus_last_scrape_duration_get(), and prometheus_metric_full_to_string().