Asterisk - The Open Source Telephony Project GIT-master-a358458
Data Fields
prometheus_callback Struct Reference

Defines a callback that will be invoked when the HTTP route is called. More...

#include <res_prometheus.h>

Data Fields

void(* callback_fn )(struct ast_str **output)
 The callback function to invoke. More...
 
const char * name
 The name of our callback (always useful for debugging) More...
 

Detailed Description

Defines a callback that will be invoked when the HTTP route is called.

This callback presents the second way of passing metrics to a Prometheus server. For metrics that are generated often or whose value needs to be stored, metrics can be created and registered. For metrics that can be obtained "on-the-fly", this mechanism is preferred. When the HTTP route is queried by prometheus, the registered callbacks are invoked. The string passed to the callback should be populated with stack-allocated metrics using prometheus_metric_to_string.

Example Usage:

static void prometheus_metric_callback(struct ast_str **output)
{
struct prometheus_metric test_counter =
"test_counter",
"A test counter",
NULL);
prometheus_metric_to_string(&test_counter, output);
}
static void load_module(void)
{
struct prometheus_callback callback = {
.name = "test_callback",
.callback_fn = &prometheus_metric_callback,
};
}
static int load_module(void)
Definition: chan_mobile.c:4778
#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.
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_callback_register(struct prometheus_callback *callback)
#define NULL
Definition: resample.c:96
Support for dynamic strings.
Definition: strings.h:623
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)
An actual, honest to god, metric.
static void prometheus_metric_callback(struct ast_str **output)

Definition at line 404 of file res_prometheus.h.

Field Documentation

◆ callback_fn

void(* callback_fn) (struct ast_str **output)

The callback function to invoke.

Definition at line 412 of file res_prometheus.h.

Referenced by prometheus_callback_register(), and scrape_metrics().

◆ name

const char* name

The name of our callback (always useful for debugging)

Definition at line 408 of file res_prometheus.h.

Referenced by AST_TEST_DEFINE(), PathSegment::get_child(), Parameter::load(), Property::load(), SwaggerType::load(), prometheus_callback_register(), and prometheus_callback_unregister().


The documentation for this struct was generated from the following file: