Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include <curl/curl.h>
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/res_prometheus.h"
Go to the source code of this file.
Macros | |
#define | CATEGORY "/res/prometheus/" |
#define | GLOBAL_USERAGENT "asterisk-libcurl-agent/1.0" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (metric_values) | |
AST_TEST_DEFINE (metric_callback_register) | |
AST_TEST_DEFINE (metric_register) | |
AST_TEST_DEFINE (counter_to_string) | |
AST_TEST_DEFINE (counter_create) | |
AST_TEST_DEFINE (gauge_to_string) | |
AST_TEST_DEFINE (gauge_create) | |
AST_TEST_DEFINE (config_general_basic_auth) | |
AST_TEST_DEFINE (config_general_enabled) | |
AST_TEST_DEFINE (config_general_core_metrics) | |
static struct prometheus_general_config * | config_alloc (void) |
static void | curl_free_wrapper (void *ptr) |
static size_t | curl_write_string_callback (void *contents, size_t size, size_t nmemb, void *userdata) |
static CURL * | get_curl_instance (void) |
static int | load_module (void) |
static void | metric_values_get_counter_value_cb (struct prometheus_metric *metric) |
static int | process_config (int reload) |
static void | prometheus_metric_callback (struct ast_str **output) |
static void | prometheus_metric_free_wrapper (void *ptr) |
static int | reload_module (void) |
static int | test_cleanup_cb (struct ast_test_info *info, struct ast_test *test) |
static int | test_init_cb (struct ast_test_info *info, struct ast_test *test) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Prometheus Core Unit Tests" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .reload = reload_module, .unload = unload_module, .requires = "res_prometheus", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
struct prometheus_general_config * | module_config |
static char | server_uri [512] |
#define CATEGORY "/res/prometheus/" |
Definition at line 35 of file test_res_prometheus.c.
Referenced by AST_TEST_DEFINE(), and load_module().
#define GLOBAL_USERAGENT "asterisk-libcurl-agent/1.0" |
Definition at line 57 of file test_res_prometheus.c.
Referenced by get_curl_instance().
|
static |
Definition at line 829 of file test_res_prometheus.c.
|
static |
Definition at line 829 of file test_res_prometheus.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 829 of file test_res_prometheus.c.
AST_TEST_DEFINE | ( | metric_values | ) |
Definition at line 117 of file test_res_prometheus.c.
References ast_free, ast_str_buffer(), ast_str_create, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, CATEGORY, curl_free_wrapper(), curl_write_string_callback(), get_curl_instance(), sip_to_pjsip::info(), metric_values_get_counter_value_cb(), NULL, PROMETHEUS_METRIC_COUNTER, prometheus_metric_register(), PROMETHEUS_METRIC_STATIC_INITIALIZATION, prometheus_metric_unregister(), RAII_VAR, result, TEST_EXECUTE, TEST_INIT, and prometheus_metric::value.
AST_TEST_DEFINE | ( | metric_callback_register | ) |
Definition at line 202 of file test_res_prometheus.c.
References ast_free, ast_str_buffer(), ast_str_create, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, CATEGORY, curl_free_wrapper(), curl_write_string_callback(), get_curl_instance(), sip_to_pjsip::info(), prometheus_callback::name, NULL, prometheus_callback_register(), prometheus_callback_unregister(), prometheus_metric_callback(), RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | metric_register | ) |
Definition at line 260 of file test_res_prometheus.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, CATEGORY, sip_to_pjsip::info(), NULL, prometheus_counter_create(), prometheus_gauge_create(), PROMETHEUS_METRIC_COUNTER, prometheus_metric_free(), prometheus_metric_free_wrapper(), prometheus_metric_register(), prometheus_metric_registered_count(), PROMETHEUS_METRIC_SET_LABEL, PROMETHEUS_METRIC_STATIC_INITIALIZATION, prometheus_metric_unregister(), RAII_VAR, result, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | counter_to_string | ) |
Definition at line 354 of file test_res_prometheus.c.
References ast_free, AST_LIST_INSERT_TAIL, ast_str_buffer(), ast_str_create, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, prometheus_metric::children, sip_to_pjsip::info(), NULL, PROMETHEUS_METRIC_COUNTER, PROMETHEUS_METRIC_SET_LABEL, PROMETHEUS_METRIC_STATIC_INITIALIZATION, prometheus_metric_to_string(), RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | counter_create | ) |
Definition at line 407 of file test_res_prometheus.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, prometheus_counter_create(), PROMETHEUS_METRIC_COUNTER, prometheus_metric_free_wrapper(), PROMETHEUS_METRIC_MALLOCD, RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | gauge_to_string | ) |
Definition at line 437 of file test_res_prometheus.c.
References ast_free, AST_LIST_INSERT_TAIL, ast_str_buffer(), ast_str_create, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, prometheus_metric::children, sip_to_pjsip::info(), NULL, PROMETHEUS_METRIC_GAUGE, PROMETHEUS_METRIC_SET_LABEL, PROMETHEUS_METRIC_STATIC_INITIALIZATION, prometheus_metric_to_string(), RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | gauge_create | ) |
Definition at line 490 of file test_res_prometheus.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, CATEGORY, sip_to_pjsip::info(), NULL, prometheus_gauge_create(), prometheus_metric_free_wrapper(), PROMETHEUS_METRIC_GAUGE, PROMETHEUS_METRIC_MALLOCD, RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | config_general_basic_auth | ) |
Definition at line 520 of file test_res_prometheus.c.
References ao2_ref, ast_string_field_set, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, prometheus_general_config::auth_password, prometheus_general_config::auth_username, CATEGORY, config, config_alloc(), curl_free_wrapper(), get_curl_instance(), sip_to_pjsip::info(), NULL, prometheus_general_config_set(), RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | config_general_enabled | ) |
Definition at line 593 of file test_res_prometheus.c.
References ao2_ref, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, CATEGORY, config, config_alloc(), curl_free_wrapper(), prometheus_general_config::enabled, get_curl_instance(), sip_to_pjsip::info(), NULL, prometheus_general_config_set(), RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | config_general_core_metrics | ) |
Definition at line 640 of file test_res_prometheus.c.
References ao2_ref, ast_free, ast_str_buffer(), ast_str_create, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, CATEGORY, config, config_alloc(), prometheus_general_config::core_metrics_enabled, curl_free_wrapper(), curl_write_string_callback(), get_curl_instance(), sip_to_pjsip::info(), NULL, prometheus_general_config_set(), RAII_VAR, TEST_EXECUTE, and TEST_INIT.
|
static |
Definition at line 59 of file test_res_prometheus.c.
References ast_string_field_set, config, prometheus_general_config::core_metrics_enabled, prometheus_general_config::enabled, NULL, prometheus_general_config_alloc(), and prometheus_general_config::uri.
Referenced by AST_TEST_DEFINE(), and test_init_cb().
|
static |
Definition at line 41 of file test_res_prometheus.c.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 94 of file test_res_prometheus.c.
References ast_free, ast_malloc, and ast_str_append().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 76 of file test_res_prometheus.c.
References GLOBAL_USERAGENT, NULL, and server_uri.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 799 of file test_res_prometheus.c.
References AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_TEST_REGISTER, ast_test_register_cleanup(), ast_test_register_init(), ASTERISK_GPL_KEY, CATEGORY, process_config(), reload(), reload_module(), test_cleanup_cb(), test_init_cb(), and unload_module().
|
static |
Definition at line 112 of file test_res_prometheus.c.
References prometheus_metric::value.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 704 of file test_res_prometheus.c.
References ast_config_destroy(), ast_config_load, ast_config_option(), ast_false(), ast_log, AST_LOG_NOTICE, bindaddr, config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, enabled, prefix, S_OR, and server_uri.
Referenced by load_module(), and reload_module().
|
static |
Definition at line 191 of file test_res_prometheus.c.
References NULL, PROMETHEUS_METRIC_COUNTER, PROMETHEUS_METRIC_STATIC_INITIALIZATION, and prometheus_metric_to_string().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 50 of file test_res_prometheus.c.
References prometheus_metric_free(), and prometheus_metric_unregister().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 776 of file test_res_prometheus.c.
References process_config().
Referenced by load_module().
|
static |
Definition at line 768 of file test_res_prometheus.c.
References ao2_cleanup, and prometheus_general_config_set().
Referenced by load_module().
|
static |
Definition at line 750 of file test_res_prometheus.c.
References ao2_ref, config_alloc(), prometheus_general_config_get(), and prometheus_general_config_set().
Referenced by load_module().
|
static |
Definition at line 781 of file test_res_prometheus.c.
References AST_TEST_UNREGISTER.
Referenced by load_module().
|
static |
Definition at line 829 of file test_res_prometheus.c.
|
static |
Definition at line 829 of file test_res_prometheus.c.
Definition at line 39 of file test_res_prometheus.c.
|
static |
Definition at line 37 of file test_res_prometheus.c.
Referenced by get_curl_instance(), and process_config().