19 #ifndef RES_PROMETHEUS_H__ 20 #define RES_PROMETHEUS_H__ 39 #define PROMETHEUS_MAX_LABELS 8 44 #define PROMETHEUS_MAX_NAME_LENGTH 64 49 #define PROMETHEUS_MAX_LABEL_LENGTH 128 54 #define PROMETHEUS_MAX_VALUE_LENGTH 32 113 void (*
const unload_cb)(void);
287 #define PROMETHEUS_METRIC_STATIC_INITIALIZATION(mtype, n, h, cb) { \ 289 .allocation_strategy = PROMETHEUS_METRIC_ALLOCD, \ 290 .lock = AST_MUTEX_INIT_VALUE, \ 293 .children = AST_LIST_HEAD_NOLOCK_INIT_VALUE, \ 294 .get_metric_value = (cb), \ 321 #define PROMETHEUS_METRIC_SET_LABEL(metric, label, n, v) do { \ 322 ast_assert((label) < PROMETHEUS_MAX_LABELS); \ 323 ast_copy_string((metric)->labels[(label)].name, (n), sizeof((metric)->labels[(label)].name)); \ 324 ast_copy_string((metric)->labels[(label)].value, (v), sizeof((metric)->labels[(label)].value)); \ 421 void (* callback_fn)(
struct ast_str **output);
unsigned int core_metrics_enabled
Whether or not core metrics are enabled.
Asterisk locking-related definitions:
An actual, honest to god, metric.
#define PROMETHEUS_MAX_VALUE_LENGTH
How large of a value we can store.
int prometheus_metric_register(struct prometheus_metric *metric)
struct prometheus_metric::@313 entry
Prometheus general configuration.
int prometheus_callback_register(struct prometheus_callback *callback)
#define PROMETHEUS_MAX_NAME_LENGTH
How long a label name can be.
prometheus_metric_allocation_strategy
How the metric was allocated.
A metric whose value always goes up.
const char * name
The name of our callback (always useful for debugging)
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
int prometheus_metric_unregister(struct prometheus_metric *metric)
Remove a registered metric.
void prometheus_metric_free(struct prometheus_metric *metric)
Destroy a metric and all its children.
void prometheus_general_config_set(struct prometheus_general_config *config)
Set the configuration for the module.
void prometheus_metric_to_string(struct prometheus_metric *metric, struct ast_str **output)
Convert a metric (and its children) into Prometheus compatible text.
The metric was allocated on the stack.
#define PROMETHEUS_MAX_LABEL_LENGTH
How long a label value can be.
#define PROMETHEUS_MAX_LABELS
How many labels a single metric can have.
#define AST_STRING_FIELD(name)
Declare a string field.
const ast_string_field auth_password
Auth password for Basic Auth.
A set of macros to manage forward-linked lists.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
void prometheus_metrics_provider_register(const struct prometheus_metrics_provider *provider)
Register a metrics provider.
struct prometheus_metric * prometheus_gauge_create(const char *name, const char *help)
Create a malloc'd gauge metric.
struct prometheus_metric::@312 children
A list of children metrics.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
const char * help
Pointer to a static string defining this metric's help text.
void * prometheus_general_config_alloc(void)
Allocate a new configuration object.
void prometheus_callback_unregister(struct prometheus_callback *callback)
Remove a registered callback.
const char * name
Handy name of the provider for debugging purposes.
const ast_string_field auth_realm
Auth realm.
const ast_string_field uri
The HTTP URI we register ourselves to.
struct prometheus_metric * prometheus_counter_create(const char *name, const char *help)
Create a malloc'd counter metric.
A function table for a metrics provider.
int prometheus_metric_registered_count(void)
ast_mutex_t lock
A lock protecting the metric value.
A label that further defines a metric.
prometheus_metric_type
Prometheus metric type.
The metric was allocated on the heap.
struct prometheus_general_config * prometheus_general_config_get(void)
Retrieve the current configuration of the module.
static struct prometheus_metrics_provider provider
Defines a callback that will be invoked when the HTTP route is called.
Structure for mutex and tracking information.
const ast_string_field auth_username
Auth username for Basic Auth.
unsigned int enabled
Whether or not the module is enabled.