33 #define BRIDGES_CHANNELS_COUNT_HELP "Number of channels in the bridge." 67 .name =
"asterisk_bridges_channels_count",
86 int i, j, num_bridges;
89 "asterisk_bridges_count",
90 "Current bridge count.",
111 snprintf(bridge_count.
value,
sizeof(bridge_count.
value),
"%d", num_bridges);
114 if (num_bridges == 0) {
120 if (!bridge_metrics) {
161 .
name =
"bridges callback",
struct ao2_container * ast_bridges(void)
Returns the global bridges container.
struct prometheus_callback bridges_callback
Asterisk main include file. File version handling, generic pbx functions.
An actual, honest to god, metric.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
Convert an EID to a string.
int prometheus_callback_register(struct prometheus_callback *callback)
#define ao2_container_clone(orig, flags)
Structure that contains a snapshot of information about a bridge.
const char * name
The name of our callback (always useful for debugging)
static void bridge_metrics_unload_cb(void)
enum prometheus_metric_type type
What type of metric we are.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
const ast_string_field creator
#define PROMETHEUS_METRIC_STATIC_INITIALIZATION(mtype, n, h, cb)
Convenience macro for initializing a metric on the stack.
void prometheus_metric_to_string(struct prometheus_metric *metric, struct ast_str **output)
Convert a metric (and its children) into Prometheus compatible text.
const ast_string_field technology
#define PROMETHEUS_METRIC_SET_LABEL(metric, label, n, v)
Convenience macro for setting a label / value in a metric.
struct ast_bridge_snapshot * ast_bridge_get_snapshot(struct ast_bridge *bridge)
Returns the current snapshot for the bridge.
#define ao2_ref(o, delta)
static void get_bridge_channel_count(struct prometheus_metric *metric, struct ast_bridge_snapshot *snapshot)
void prometheus_metrics_provider_register(const struct prometheus_metrics_provider *provider)
Register a metrics provider.
Structure that contains information about a bridge.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
const ast_string_field name
#define BRIDGES_CHANNELS_COUNT_HELP
#define ao2_iterator_next(iter)
char value[PROMETHEUS_MAX_VALUE_LENGTH]
The current value.
static struct ao2_container * bridges
const char * help
Pointer to a static string defining this metric's help text.
#define ast_calloc(num, len)
A wrapper for calloc()
const ast_string_field uniqueid
void prometheus_callback_unregister(struct prometheus_callback *callback)
Remove a registered callback.
unsigned int num_channels
const char * name
Handy name of the provider for debugging purposes.
struct ast_eid ast_eid_default
Global EID.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
A function table for a metrics provider.
static void bridges_scrape_cb(struct ast_str **response)
const char * name
Name of the metric.
const char * help
Help text to display.
const ast_string_field subclass
static struct prometheus_metrics_provider provider
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
Defines a callback that will be invoked when the HTTP route is called.
void(*const get_value)(struct prometheus_metric *metric, struct ast_bridge_snapshot *snapshot)
Callback function to generate a metric value for a given bridge.
int bridge_metrics_init(void)
Initialize bridge metrics.