Asterisk - The Open Source Telephony Project
18.5.0
|
Go to the source code of this file.
Data Structures | |
struct | prometheus_callback |
Defines a callback that will be invoked when the HTTP route is called. More... | |
struct | prometheus_general_config |
Prometheus general configuration. More... | |
struct | prometheus_label |
A label that further defines a metric. More... | |
struct | prometheus_metric |
An actual, honest to god, metric. More... | |
struct | prometheus_metrics_provider |
A function table for a metrics provider. More... | |
Macros | |
#define | PROMETHEUS_MAX_LABEL_LENGTH 128 |
How long a label value can be. More... | |
#define | PROMETHEUS_MAX_LABELS 8 |
How many labels a single metric can have. More... | |
#define | PROMETHEUS_MAX_NAME_LENGTH 64 |
How long a label name can be. More... | |
#define | PROMETHEUS_MAX_VALUE_LENGTH 32 |
How large of a value we can store. More... | |
#define | PROMETHEUS_METRIC_SET_LABEL(metric, label, n, v) |
Convenience macro for setting a label / value in a metric. More... | |
#define | PROMETHEUS_METRIC_STATIC_INITIALIZATION(mtype, n, h, cb) |
Convenience macro for initializing a metric on the stack. More... | |
Enumerations | |
enum | prometheus_metric_allocation_strategy { PROMETHEUS_METRIC_ALLOCD = 0, PROMETHEUS_METRIC_MALLOCD } |
How the metric was allocated. More... | |
enum | prometheus_metric_type { PROMETHEUS_METRIC_COUNTER = 0, PROMETHEUS_METRIC_GAUGE } |
Prometheus metric type. More... | |
Functions | |
int | prometheus_callback_register (struct prometheus_callback *callback) |
void | prometheus_callback_unregister (struct prometheus_callback *callback) |
Remove a registered callback. More... | |
struct prometheus_metric * | prometheus_counter_create (const char *name, const char *help) |
Create a malloc'd counter metric. More... | |
struct prometheus_metric * | prometheus_gauge_create (const char *name, const char *help) |
Create a malloc'd gauge metric. More... | |
void * | prometheus_general_config_alloc (void) |
Allocate a new configuration object. More... | |
struct prometheus_general_config * | prometheus_general_config_get (void) |
Retrieve the current configuration of the module. More... | |
void | prometheus_general_config_set (struct prometheus_general_config *config) |
Set the configuration for the module. More... | |
void | prometheus_metric_free (struct prometheus_metric *metric) |
Destroy a metric and all its children. More... | |
int | prometheus_metric_register (struct prometheus_metric *metric) |
int | prometheus_metric_registered_count (void) |
void | prometheus_metric_to_string (struct prometheus_metric *metric, struct ast_str **output) |
Convert a metric (and its children) into Prometheus compatible text. More... | |
int | prometheus_metric_unregister (struct prometheus_metric *metric) |
Remove a registered metric. More... | |
void | prometheus_metrics_provider_register (const struct prometheus_metrics_provider *provider) |
Register a metrics provider. More... | |
#define PROMETHEUS_MAX_LABEL_LENGTH 128 |
How long a label value can be.
Definition at line 49 of file res_prometheus.h.
#define PROMETHEUS_MAX_LABELS 8 |
How many labels a single metric can have.
Definition at line 39 of file res_prometheus.h.
Referenced by prometheus_metric_cmp(), and prometheus_metric_full_to_string().
#define PROMETHEUS_MAX_NAME_LENGTH 64 |
How long a label name can be.
Definition at line 44 of file res_prometheus.h.
#define PROMETHEUS_MAX_VALUE_LENGTH 32 |
How large of a value we can store.
Definition at line 54 of file res_prometheus.h.
#define PROMETHEUS_METRIC_SET_LABEL | ( | metric, | |
label, | |||
n, | |||
v | |||
) |
Convenience macro for setting a label / value in a metric.
metric | The metric to set the label on |
label | Position of the label to set |
n | Name of the label |
v | Value of the label |
When creating nested metrics, it's helpful to set their label after they have been declared but before they have been registered. This macro acts as a convenience function to set the labels properly on a declared metric.
Example Usage:
Definition at line 321 of file res_prometheus.h.
Referenced by AST_TEST_DEFINE(), bridges_scrape_cb(), channels_scrape_cb(), endpoints_scrape_cb(), prometheus_config_post_apply(), and registry_message_cb().
#define PROMETHEUS_METRIC_STATIC_INITIALIZATION | ( | mtype, | |
n, | |||
h, | |||
cb | |||
) |
Convenience macro for initializing a metric on the stack.
mtype | The metric type. See prometheus_metric_type |
n | Name of the metric |
h | Help text for the metric |
cb | Callback function. Optional; may be NULL |
When initializing a metric on the stack, various fields have to be provided to initialize the metric correctly. This macro can be used to simplify the process.
Example Usage:
Definition at line 287 of file res_prometheus.h.
Referenced by AST_TEST_DEFINE(), bridges_scrape_cb(), channels_scrape_cb(), endpoints_scrape_cb(), prometheus_metric_callback(), and registry_message_cb().
How the metric was allocated.
Enumerator | |
---|---|
PROMETHEUS_METRIC_ALLOCD | The metric was allocated on the stack. |
PROMETHEUS_METRIC_MALLOCD | The metric was allocated on the heap. |
Definition at line 140 of file res_prometheus.h.
Prometheus metric type.
Enumerator | |
---|---|
PROMETHEUS_METRIC_COUNTER | A metric whose value always goes up. |
PROMETHEUS_METRIC_GAUGE |
Definition at line 124 of file res_prometheus.h.
int prometheus_callback_register | ( | struct prometheus_callback * | callback | ) |
Register a metric callback
callback | The callback to register |
0 | success |
-1 | error |
Definition at line 535 of file res_prometheus.c.
References ast_strlen_zero, AST_VECTOR_APPEND, prometheus_callback::callback_fn, lock, prometheus_callback::name, SCOPED_MUTEX, and scrape_lock.
Referenced by AST_TEST_DEFINE(), bridge_metrics_init(), channel_metrics_init(), and endpoint_metrics_init().
void prometheus_callback_unregister | ( | struct prometheus_callback * | callback | ) |
Remove a registered callback.
callback | The callback to unregister |
Definition at line 548 of file res_prometheus.c.
References AST_VECTOR_GET, AST_VECTOR_REMOVE, AST_VECTOR_SIZE, lock, prometheus_callback::name, SCOPED_MUTEX, and scrape_lock.
Referenced by AST_TEST_DEFINE(), bridge_metrics_unload_cb(), channel_metrics_unload_cb(), and endpoint_metrics_unload_cb().
struct prometheus_metric* prometheus_counter_create | ( | const char * | name, |
const char * | help | ||
) |
Create a malloc'd counter metric.
name | The name of the metric |
help | Help text for the metric |
prometheus_metric | on success |
NULL | on error |
Definition at line 452 of file res_prometheus.c.
References NULL, PROMETHEUS_METRIC_COUNTER, prometheus_metric_create(), and prometheus_metric::type.
Referenced by AST_TEST_DEFINE().
struct prometheus_metric* prometheus_gauge_create | ( | const char * | name, |
const char * | help | ||
) |
Create a malloc'd gauge metric.
name | The name of the metric |
help | Help text for the metric |
prometheus_metric | on success |
NULL | on error |
Definition at line 439 of file res_prometheus.c.
References NULL, prometheus_metric_create(), PROMETHEUS_METRIC_GAUGE, and prometheus_metric::type.
Referenced by AST_TEST_DEFINE(), and registry_message_cb().
void* prometheus_general_config_alloc | ( | void | ) |
Allocate a new configuration object.
The returned object is an AO2 ref counted object
NULL | on error |
config | on success |
Definition at line 726 of file res_prometheus.c.
References ao2_alloc, ast_string_field_init, config, NULL, and prometheus_general_config_dtor().
Referenced by config_alloc(), and module_config_alloc().
struct prometheus_general_config* prometheus_general_config_get | ( | void | ) |
Retrieve the current configuration of the module.
config is an AO2 ref counted object
NULL | on error |
config | on success |
Definition at line 738 of file res_prometheus.c.
References ao2_bump, ao2_cleanup, ao2_global_obj_ref, NULL, and RAII_VAR.
Referenced by prometheus_show_status(), reload_module(), and test_init_cb().
void prometheus_general_config_set | ( | struct prometheus_general_config * | config | ) |
Set the configuration for the module.
This is not a ref-stealing function. The reference count to config
will be incremented as a result of calling this method.
Definition at line 750 of file res_prometheus.c.
References ao2_cleanup, ao2_global_obj_ref, ao2_replace, prometheus_config_post_apply(), and RAII_VAR.
Referenced by AST_TEST_DEFINE(), test_cleanup_cb(), and test_init_cb().
void prometheus_metric_free | ( | struct prometheus_metric * | metric | ) |
Destroy a metric and all its children.
children
list first.metric | The metric to destroy |
Definition at line 392 of file res_prometheus.c.
References prometheus_metric::allocation_strategy, ast_free, AST_LIST_REMOVE_HEAD, ast_mutex_destroy, prometheus_metric::children, prometheus_metric::lock, PROMETHEUS_METRIC_ALLOCD, and PROMETHEUS_METRIC_MALLOCD.
Referenced by AST_TEST_DEFINE(), prometheus_metric_free_wrapper(), prometheus_metric_unregister(), and unload_module().
int prometheus_metric_register | ( | struct prometheus_metric * | metric | ) |
Register a metric for collection
metric | The metric to register |
0 | success |
-1 | error |
Definition at line 287 of file res_prometheus.c.
References ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log, AST_LOG_NOTICE, AST_LOG_WARNING, AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_SIZE, prometheus_metric::children, lock, prometheus_metric::name, prometheus_metric_cmp(), SCOPED_MUTEX, and scrape_lock.
Referenced by AST_TEST_DEFINE(), prometheus_config_post_apply(), and registry_message_cb().
int prometheus_metric_registered_count | ( | void | ) |
The current number of registered metrics
The | current number of registered metrics |
Definition at line 280 of file res_prometheus.c.
References AST_VECTOR_SIZE, lock, SCOPED_MUTEX, and scrape_lock.
Referenced by AST_TEST_DEFINE().
void prometheus_metric_to_string | ( | struct prometheus_metric * | metric, |
struct ast_str ** | output | ||
) |
Convert a metric (and its children) into Prometheus compatible text.
metric | The metric to convert to a string | |
[out] | output | The ast_str string to populate with the metric(s) |
Definition at line 521 of file res_prometheus.c.
References AST_LIST_TRAVERSE, ast_str_append(), prometheus_metric::children, prometheus_metric::help, prometheus_metric::name, prometheus_metric_full_to_string(), prometheus_metric_type_to_string(), and prometheus_metric::type.
Referenced by AST_TEST_DEFINE(), bridges_scrape_cb(), channels_scrape_cb(), endpoints_scrape_cb(), http_callback(), prometheus_metric_callback(), and scrape_metrics().
int prometheus_metric_unregister | ( | struct prometheus_metric * | metric | ) |
Remove a registered metric.
metric | The metric to unregister |
0 | The metric was found, unregistered, and disposed of |
-1 | The metric was not found |
Definition at line 334 of file res_prometheus.c.
References ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_VECTOR_GET, AST_VECTOR_INSERT_AT, AST_VECTOR_REMOVE, AST_VECTOR_SIZE, prometheus_metric::children, lock, prometheus_metric::name, prometheus_metric_cmp(), prometheus_metric_free(), SCOPED_MUTEX, and scrape_lock.
Referenced by AST_TEST_DEFINE(), prometheus_config_post_apply(), prometheus_metric_free_wrapper(), registration_deleted_observer(), and registration_loaded_observer().
void prometheus_metrics_provider_register | ( | const struct prometheus_metrics_provider * | provider | ) |
Register a metrics provider.
provider | The provider function table to register |
Definition at line 871 of file res_prometheus.c.
References AST_VECTOR_APPEND, and providers.
Referenced by bridge_metrics_init(), channel_metrics_init(), cli_init(), endpoint_metrics_init(), and pjsip_outbound_registration_metrics_init().