Asterisk - The Open Source Telephony Project GIT-master-545c459
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
res_prometheus.h File Reference

Asterisk Prometheus Metrics. More...

#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
Include dependency graph for res_prometheus.h:
This graph shows which files directly or indirectly include this file:

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.
 
#define PROMETHEUS_MAX_LABELS   8
 How many labels a single metric can have.
 
#define PROMETHEUS_MAX_NAME_LENGTH   64
 How long a label name can be.
 
#define PROMETHEUS_MAX_VALUE_LENGTH   32
 How large of a value we can store.
 
#define PROMETHEUS_METRIC_SET_LABEL(metric, label, n, v)
 Convenience macro for setting a label / value in a metric.
 
#define PROMETHEUS_METRIC_STATIC_INITIALIZATION(mtype, n, h, cb)
 Convenience macro for initializing a metric on the stack.
 

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.
 
struct prometheus_metricprometheus_counter_create (const char *name, const char *help)
 Create a malloc'd counter metric.
 
struct prometheus_metricprometheus_gauge_create (const char *name, const char *help)
 Create a malloc'd gauge metric.
 
void * prometheus_general_config_alloc (void)
 Allocate a new configuration object.
 
struct prometheus_general_configprometheus_general_config_get (void)
 Retrieve the current configuration of the module.
 
void prometheus_general_config_set (struct prometheus_general_config *config)
 Set the configuration for the module.
 
void prometheus_metric_free (struct prometheus_metric *metric)
 Destroy a metric and all its children.
 
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.
 
int prometheus_metric_unregister (struct prometheus_metric *metric)
 Remove a registered metric.
 
void prometheus_metrics_provider_register (const struct prometheus_metrics_provider *provider)
 Register a metrics provider.
 

Detailed Description

Asterisk Prometheus Metrics.

This module provides the base APIs and functionality for exposing a metrics route in Asterisk's HTTP server suitable for consumption by a Prometheus server. It does not provide any metrics itself.

Definition in file res_prometheus.h.

Macro Definition Documentation

◆ PROMETHEUS_MAX_LABEL_LENGTH

#define PROMETHEUS_MAX_LABEL_LENGTH   128

How long a label value can be.

Definition at line 49 of file res_prometheus.h.

◆ PROMETHEUS_MAX_LABELS

#define PROMETHEUS_MAX_LABELS   8

How many labels a single metric can have.

Definition at line 39 of file res_prometheus.h.

◆ PROMETHEUS_MAX_NAME_LENGTH

#define PROMETHEUS_MAX_NAME_LENGTH   64

How long a label name can be.

Definition at line 44 of file res_prometheus.h.

◆ PROMETHEUS_MAX_VALUE_LENGTH

#define PROMETHEUS_MAX_VALUE_LENGTH   32

How large of a value we can store.

Definition at line 54 of file res_prometheus.h.

◆ PROMETHEUS_METRIC_SET_LABEL

#define PROMETHEUS_METRIC_SET_LABEL (   metric,
  label,
  n,
 
)
Value:
do { \
ast_assert((label) < PROMETHEUS_MAX_LABELS); \
ast_copy_string((metric)->labels[(label)].name, (n), sizeof((metric)->labels[(label)].name)); \
ast_copy_string((metric)->labels[(label)].value, (v), sizeof((metric)->labels[(label)].value)); \
} while (0)
static const char name[]
Definition format_mp3.c:68
#define PROMETHEUS_MAX_LABELS
How many labels a single metric can have.
int value
Definition syslog.c:37

Convenience macro for setting a label / value in a metric.

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.

Note
Setting labels after registration will lead to a "bad time"

Example Usage:

test_gauge_child_two, 0, "key_one", "value_two");
test_gauge_child_two, 1, "key_two", "value_two");
#define PROMETHEUS_METRIC_SET_LABEL(metric, label, n, v)
Convenience macro for setting a label / value in a metric.
Parameters
metricThe metric to set the label on
labelPosition of the label to set
nName of the label
vValue of the label

Definition at line 317 of file res_prometheus.h.

317 { \
318 ast_assert((label) < PROMETHEUS_MAX_LABELS); \
319 ast_copy_string((metric)->labels[(label)].name, (n), sizeof((metric)->labels[(label)].name)); \
320 ast_copy_string((metric)->labels[(label)].value, (v), sizeof((metric)->labels[(label)].value)); \
321} while (0)

◆ PROMETHEUS_METRIC_STATIC_INITIALIZATION

#define PROMETHEUS_METRIC_STATIC_INITIALIZATION (   mtype,
  n,
  h,
  cb 
)

Convenience macro for initializing a metric on the stack.

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:

struct prometheus_metric test_counter_one =
"test_counter_one",
"A test counter",
NULL);
struct prometheus_metric test_counter_two =
"test_counter_two",
"A test counter",
#define PROMETHEUS_METRIC_STATIC_INITIALIZATION(mtype, n, h, cb)
Convenience macro for initializing a metric on the stack.
@ PROMETHEUS_METRIC_COUNTER
A metric whose value always goes up.
#define NULL
Definition resample.c:96
An actual, honest to god, metric.
static void metric_values_get_counter_value_cb(struct prometheus_metric *metric)
Parameters
mtypeThe metric type. See prometheus_metric_type
nName of the metric
hHelp text for the metric
cbCallback function. Optional; may be NULL

Definition at line 285 of file res_prometheus.h.

285 { \
286 .type = (mtype), \
287 .allocation_strategy = PROMETHEUS_METRIC_ALLOCD, \
289 .name = (n), \
290 .help = (h), \
292 .get_metric_value = (cb), \
293}
ast_mutex_t lock
Definition app_sla.c:337
const char * mtype
Definition http.c:152
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
#define AST_MUTEX_INIT_VALUE
Definition lock.h:102
@ PROMETHEUS_METRIC_ALLOCD
The metric was allocated on the stack.

Enumeration Type Documentation

◆ prometheus_metric_allocation_strategy

How the metric was allocated.

Note
Clearly, you don't want to get this wrong.
Enumerator
PROMETHEUS_METRIC_ALLOCD 

The metric was allocated on the stack.

PROMETHEUS_METRIC_MALLOCD 

The metric was allocated on the heap.

Definition at line 142 of file res_prometheus.h.

142 {
143 /*!
144 * \brief The metric was allocated on the stack
145 */
147 /*!
148 * \brief The metric was allocated on the heap
149 */
151};
@ PROMETHEUS_METRIC_MALLOCD
The metric was allocated on the heap.

◆ prometheus_metric_type

Prometheus metric type.

Note
Clearly, at some point, we should support summaries and histograms. As an initial implementation, counters / gauges give us quite a bit of functionality.
Enumerator
PROMETHEUS_METRIC_COUNTER 

A metric whose value always goes up.

PROMETHEUS_METRIC_GAUGE 

A metric whose value can bounce around like a jackrabbit.

Definition at line 126 of file res_prometheus.h.

126 {
127 /*!
128 * \brief A metric whose value always goes up
129 */
131 /*!
132 * \brief A metric whose value can bounce around like a jackrabbit
133 */
135};
@ PROMETHEUS_METRIC_GAUGE
A metric whose value can bounce around like a jackrabbit.

Function Documentation

◆ prometheus_callback_register()

int prometheus_callback_register ( struct prometheus_callback callback)

Register a metric callback

Parameters
callbackThe callback to register
Return values
0success
-1error

Definition at line 594 of file res_prometheus.c.

595{
597
598 if (!callback || !callback->callback_fn || ast_strlen_zero(callback->name)) {
599 return -1;
600 }
601
603
604 return 0;
605}
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags, int rdlock)
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
Definition lock.h:596
static ast_mutex_t scrape_lock
Lock that protects data structures during an HTTP scrape.
struct @510 callbacks
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition vector.h:267

References ast_strlen_zero(), AST_VECTOR_APPEND, callback(), callbacks, lock, SCOPED_MUTEX, and scrape_lock.

Referenced by AST_TEST_DEFINE(), bridge_metrics_init(), channel_metrics_init(), and endpoint_metrics_init().

◆ prometheus_callback_unregister()

void prometheus_callback_unregister ( struct prometheus_callback callback)

Remove a registered callback.

Parameters
callbackThe callback to unregister

Definition at line 607 of file res_prometheus.c.

608{
610 int i;
611
612 for (i = 0; i < AST_VECTOR_SIZE(&callbacks); i++) {
613 struct prometheus_callback *entry = AST_VECTOR_GET(&callbacks, i);
614
615 if (!strcmp(callback->name, entry->name)) {
617 return;
618 }
619 }
620}
Defines a callback that will be invoked when the HTTP route is called.
const char * name
The name of our callback (always useful for debugging)
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition vector.h:637
#define AST_VECTOR_REMOVE(vec, idx, preserve_ordered)
Remove an element from a vector by index.
Definition vector.h:440
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition vector.h:708

References AST_VECTOR_GET, AST_VECTOR_REMOVE, AST_VECTOR_SIZE, callback(), callbacks, 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().

◆ prometheus_counter_create()

struct prometheus_metric * prometheus_counter_create ( const char *  name,
const char *  help 
)

Create a malloc'd counter metric.

Note
The metric must be registered after creation
Parameters
nameThe name of the metric
helpHelp text for the metric
Return values
prometheus_metricon success
NULLon error

Definition at line 511 of file res_prometheus.c.

512{
513 struct prometheus_metric *metric;
514
516 if (!metric) {
517 return NULL;
518 }
520
521 return metric;
522}
static struct prometheus_metric * prometheus_metric_create(const char *name, const char *help)
const char * help
Pointer to a static string defining this metric's help text.
enum prometheus_metric_type type
What type of metric we are.

References prometheus_metric::help, name, NULL, PROMETHEUS_METRIC_COUNTER, prometheus_metric_create(), and prometheus_metric::type.

Referenced by AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ prometheus_gauge_create()

struct prometheus_metric * prometheus_gauge_create ( const char *  name,
const char *  help 
)

Create a malloc'd gauge metric.

Note
The metric must be registered after creation
Parameters
nameThe name of the metric
helpHelp text for the metric
Return values
prometheus_metricon success
NULLon error

Definition at line 498 of file res_prometheus.c.

499{
500 struct prometheus_metric *metric;
501
503 if (!metric) {
504 return NULL;
505 }
507
508 return metric;
509}

References prometheus_metric::help, name, NULL, prometheus_metric_create(), PROMETHEUS_METRIC_GAUGE, and prometheus_metric::type.

Referenced by AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ prometheus_general_config_alloc()

void * prometheus_general_config_alloc ( void  )

Allocate a new configuration object.

The returned object is an AO2 ref counted object

Return values
NULLon error
configon success

Definition at line 792 of file res_prometheus.c.

793{
795
797 if (!config || ast_string_field_init(config, 32)) {
798 return NULL;
799 }
800
801 return config;
802}
#define ao2_alloc(data_size, destructor_fn)
Definition astobj2.h:409
static const char config[]
static void prometheus_general_config_dtor(void *obj)
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Prometheus general configuration.

References ao2_alloc, ast_string_field_init, config, NULL, and prometheus_general_config_dtor().

Referenced by config_alloc(), and module_config_alloc().

◆ prometheus_general_config_get()

struct prometheus_general_config * prometheus_general_config_get ( void  )

Retrieve the current configuration of the module.

config is an AO2 ref counted object

Note
This should primarily be done for testing purposes.
Return values
NULLon error
configon success

Definition at line 804 of file res_prometheus.c.

805{
807
808 if (!mod_cfg) {
809 return NULL;
810 }
811 ao2_bump(mod_cfg->general);
812
813 return mod_cfg->general;
814}
#define ao2_cleanup(obj)
Definition astobj2.h:1934
#define ao2_global_obj_ref(holder)
Get a reference to the object stored in the global holder.
Definition astobj2.h:918
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480
The configuration settings for this module.
Definition cdr.c:326
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981

References ao2_bump, ao2_cleanup, ao2_global_obj_ref, NULL, and RAII_VAR.

Referenced by bridges_scrape_cb(), channels_scrape_cb(), prometheus_show_status(), reload_module(), and test_init_cb().

◆ prometheus_general_config_set()

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.

Note
This should primarily be done for testing purposes

Definition at line 816 of file res_prometheus.c.

817{
819
820 if (!mod_cfg) {
821 return;
822 }
823 ao2_replace(mod_cfg->general, config);
825}
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition astobj2.h:501
static void prometheus_config_post_apply(void)
Post-apply callback for the config framework.

References ao2_cleanup, ao2_global_obj_ref, ao2_replace, config, prometheus_config_post_apply(), and RAII_VAR.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), test_cleanup_cb(), and test_init_cb().

◆ prometheus_metric_free()

void prometheus_metric_free ( struct prometheus_metric metric)

Destroy a metric and all its children.

Note
If you still want the children, make sure you remove the head of the children list first.
Parameters
metricThe metric to destroy

Definition at line 452 of file res_prometheus.c.

453{
454 struct prometheus_metric *child;
455
456 if (!metric) {
457 return;
458 }
459
460 while ((child = AST_LIST_REMOVE_HEAD(&metric->children, entry))) {
462 }
463 ast_mutex_destroy(&metric->lock);
464
466 return;
467 } else if (metric->allocation_strategy == PROMETHEUS_METRIC_MALLOCD) {
468 ast_free(metric);
469 }
470}
#define ast_free(a)
Definition astmm.h:180
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define ast_mutex_destroy(a)
Definition lock.h:195
void prometheus_metric_free(struct prometheus_metric *metric)
Destroy a metric and all its children.
struct prometheus_metric::@288 entry
enum prometheus_metric_allocation_strategy allocation_strategy
How this metric was allocated.
ast_mutex_t lock
A lock protecting the metric value.
struct prometheus_metric::@287 children
A list of children metrics.

References prometheus_metric::allocation_strategy, ast_free, AST_LIST_REMOVE_HEAD, ast_mutex_destroy, prometheus_metric::children, prometheus_metric::entry, prometheus_metric::lock, PROMETHEUS_METRIC_ALLOCD, prometheus_metric_free(), and PROMETHEUS_METRIC_MALLOCD.

Referenced by AST_TEST_DEFINE(), prometheus_metric_free(), prometheus_metric_free_wrapper(), prometheus_metric_unregister(), and unload_module().

◆ prometheus_metric_register()

int prometheus_metric_register ( struct prometheus_metric metric)

Register a metric for collection

Parameters
metricThe metric to register
Return values
0success
-1error

Definition at line 347 of file res_prometheus.c.

348{
350 int i;
351
352 if (!metric) {
353 return -1;
354 }
355
356 for (i = 0; i < AST_VECTOR_SIZE(&metrics); i++) {
357 struct prometheus_metric *existing = AST_VECTOR_GET(&metrics, i);
358 struct prometheus_metric *child;
359
360 if (prometheus_metric_cmp(existing, metric)) {
362 "Refusing registration of existing Prometheus metric: %s\n",
363 metric->name);
364 return -1;
365 }
366
367 AST_LIST_TRAVERSE(&existing->children, child, entry) {
368 if (prometheus_metric_cmp(child, metric)) {
370 "Refusing registration of existing Prometheus metric: %s\n",
371 metric->name);
372 return -1;
373 }
374 }
375
376 if (!strcmp(metric->name, existing->name)) {
377 ast_debug(3, "Nesting metric '%s' as child (%p) under existing (%p)\n",
378 metric->name, metric, existing);
379 AST_LIST_INSERT_TAIL(&existing->children, metric, entry);
380 return 0;
381 }
382 }
383
384 ast_debug(3, "Tracking new root metric '%s'\n", metric->name);
385 if (AST_VECTOR_APPEND(&metrics, metric)) {
386 ast_log(AST_LOG_WARNING, "Failed to grow vector to make room for Prometheus metric: %s\n",
387 metric->name);
388 return -1;
389 }
390
391 return 0;
392}
#define ast_log
Definition astobj2.c:42
#define AST_LOG_WARNING
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LOG_NOTICE
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
struct @509 metrics
static int prometheus_metric_cmp(struct prometheus_metric *left, struct prometheus_metric *right)
char name[PROMETHEUS_MAX_NAME_LENGTH]
Our metric name.

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, prometheus_metric::entry, lock, metrics, prometheus_metric::name, prometheus_metric_cmp(), SCOPED_MUTEX, and scrape_lock.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), and prometheus_config_post_apply().

◆ prometheus_metric_registered_count()

int prometheus_metric_registered_count ( void  )

The current number of registered metrics

Return values
Thecurrent number of registered metrics

Definition at line 340 of file res_prometheus.c.

341{
343
344 return AST_VECTOR_SIZE(&metrics);
345}

References AST_VECTOR_SIZE, lock, metrics, SCOPED_MUTEX, and scrape_lock.

Referenced by AST_TEST_DEFINE().

◆ prometheus_metric_to_string()

void prometheus_metric_to_string ( struct prometheus_metric metric,
struct ast_str **  output 
)

Convert a metric (and its children) into Prometheus compatible text.

Parameters
metricThe metric to convert to a string
[out]outputThe ast_str string to populate with the metric(s)

Definition at line 580 of file res_prometheus.c.

582{
583 struct prometheus_metric *child;
584
585 ast_str_append(output, 0, "# HELP %s %s\n", metric->name, metric->help);
586 ast_str_append(output, 0, "# TYPE %s %s\n", metric->name,
588 prometheus_metric_full_to_string(metric, output);
589 AST_LIST_TRAVERSE(&metric->children, child, entry) {
591 }
592}
static void prometheus_metric_full_to_string(struct prometheus_metric *metric, struct ast_str **output)
static const char * prometheus_metric_type_to_string(enum prometheus_metric_type type)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139

References AST_LIST_TRAVERSE, ast_str_append(), prometheus_metric::children, prometheus_metric::entry, 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(), AST_TEST_DEFINE(), bridges_scrape_cb(), channels_scrape_cb(), endpoints_scrape_cb(), http_callback(), prometheus_metric_callback(), and scrape_metrics().

◆ prometheus_metric_unregister()

int prometheus_metric_unregister ( struct prometheus_metric metric)

Remove a registered metric.

Parameters
metricThe metric to unregister
Note
Unregistering also destroys the metric, if found
Return values
0The metric was found, unregistered, and disposed of
-1The metric was not found

Definition at line 394 of file res_prometheus.c.

395{
396 if (!metric) {
397 return -1;
398 }
399
400 {
402 int i;
403
404 ast_debug(3, "Removing metric '%s'\n", metric->name);
405 for (i = 0; i < AST_VECTOR_SIZE(&metrics); i++) {
406 struct prometheus_metric *existing = AST_VECTOR_GET(&metrics, i);
407
408 /*
409 * If this is a complete match, remove the matching metric
410 * and place its children back into the list
411 */
412 if (prometheus_metric_cmp(existing, metric)) {
413 struct prometheus_metric *root;
414
416 root = AST_LIST_REMOVE_HEAD(&existing->children, entry);
417 if (root) {
418 struct prometheus_metric *child;
419 AST_LIST_TRAVERSE_SAFE_BEGIN(&existing->children, child, entry) {
421 AST_LIST_INSERT_TAIL(&root->children, child, entry);
422 }
424 AST_VECTOR_INSERT_AT(&metrics, i, root);
425 }
426 prometheus_metric_free(existing);
427 return 0;
428 }
429
430 /*
431 * Name match, but labels don't match. Find the matching entry with
432 * labels and remove it along with all of its children
433 */
434 if (!strcmp(existing->name, metric->name)) {
435 struct prometheus_metric *child;
436
437 AST_LIST_TRAVERSE_SAFE_BEGIN(&existing->children, child, entry) {
438 if (prometheus_metric_cmp(child, metric)) {
441 return 0;
442 }
443 }
445 }
446 }
447 }
448
449 return -1;
450}
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_VECTOR_INSERT_AT(vec, idx, elem)
Insert an element at a specific position in a vector, growing the vector if needed.
Definition vector.h:349

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, prometheus_metric::entry, lock, metrics, prometheus_metric::name, prometheus_metric_cmp(), prometheus_metric_free(), SCOPED_MUTEX, and scrape_lock.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), prometheus_config_post_apply(), and prometheus_metric_free_wrapper().

◆ prometheus_metrics_provider_register()

void prometheus_metrics_provider_register ( const struct prometheus_metrics_provider provider)

Register a metrics provider.

Parameters
providerThe provider function table to register

Definition at line 937 of file res_prometheus.c.

938{
940}
static struct prometheus_metrics_provider provider
Definition bridges.c:207
struct @511 providers

References AST_VECTOR_APPEND, provider, and providers.

Referenced by bridge_metrics_init(), channel_metrics_init(), cli_init(), endpoint_metrics_init(), and pjsip_outbound_registration_metrics_init().