Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include <curl/curl.h>
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_basic.h"
#include "asterisk/config.h"
#include "asterisk/res_prometheus.h"
#include "../res/prometheus/prometheus_internal.h"
Go to the source code of this file.
Macros | |
#define | CATEGORY "/res/prometheus/" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (bridge_to_string) | |
AST_TEST_DEFINE (config_general_basic_auth) | |
AST_TEST_DEFINE (config_general_core_metrics) | |
AST_TEST_DEFINE (config_general_enabled) | |
AST_TEST_DEFINE (counter_create) | |
AST_TEST_DEFINE (counter_to_string) | |
AST_TEST_DEFINE (gauge_create) | |
AST_TEST_DEFINE (gauge_to_string) | |
AST_TEST_DEFINE (metric_callback_register) | |
AST_TEST_DEFINE (metric_register) | |
AST_TEST_DEFINE (metric_values) | |
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 int | match_count (const char *str, const char *needle) |
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 void | safe_bridge_destroy (struct ast_bridge *bridge) |
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 38 of file test_res_prometheus.c.
|
static |
Definition at line 897 of file test_res_prometheus.c.
|
static |
Definition at line 897 of file test_res_prometheus.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 897 of file test_res_prometheus.c.
AST_TEST_DEFINE | ( | bridge_to_string | ) |
Definition at line 725 of file test_res_prometheus.c.
References ast_bridge_base_new(), ast_bridge_basic_new(), AST_BRIDGE_CAPABILITY_HOLDING, AST_BRIDGE_FLAG_INVISIBLE, ast_free, ast_str_buffer(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, CATEGORY, sip_to_pjsip::info(), match_count(), NULL, prometheus_scrape_to_string(), RAII_VAR, safe_bridge_destroy(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | config_general_basic_auth | ) |
Definition at line 521 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_core_metrics | ) |
Definition at line 641 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(), 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.
AST_TEST_DEFINE | ( | config_general_enabled | ) |
Definition at line 594 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(), get_curl_instance(), sip_to_pjsip::info(), NULL, prometheus_general_config_set(), RAII_VAR, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | counter_create | ) |
Definition at line 408 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 | ( | counter_to_string | ) |
Definition at line 355 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 | ( | gauge_create | ) |
Definition at line 491 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 | ( | gauge_to_string | ) |
Definition at line 438 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 | ( | metric_callback_register | ) |
Definition at line 203 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 261 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 | ( | metric_values | ) |
Definition at line 118 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.
|
static |
Definition at line 60 of file test_res_prometheus.c.
References ast_string_field_set, config, NULL, prometheus_general_config_alloc(), and prometheus_general_config::uri.
Referenced by AST_TEST_DEFINE(), and test_init_cb().
|
static |
Definition at line 44 of file test_res_prometheus.c.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 95 of file test_res_prometheus.c.
References ast_free, ast_malloc, ast_str_append(), and contents.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 77 of file test_res_prometheus.c.
References AST_CURL_USER_AGENT, NULL, and server_uri.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 865 of file test_res_prometheus.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_TEST_REGISTER, CATEGORY, process_config(), test_cleanup_cb(), and test_init_cb().
|
static |
Definition at line 713 of file test_res_prometheus.c.
References str.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 113 of file test_res_prometheus.c.
References prometheus_metric::value.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 768 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, reload(), S_OR, and server_uri.
Referenced by load_module(), and reload_module().
|
static |
Definition at line 192 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 53 of file test_res_prometheus.c.
References prometheus_metric_free(), and prometheus_metric_unregister().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 840 of file test_res_prometheus.c.
References process_config().
|
static |
Definition at line 705 of file test_res_prometheus.c.
References ast_bridge_destroy().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 832 of file test_res_prometheus.c.
References ao2_cleanup, and prometheus_general_config_set().
Referenced by load_module().
|
static |
Definition at line 814 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 845 of file test_res_prometheus.c.
References AST_TEST_UNREGISTER.
|
static |
Definition at line 897 of file test_res_prometheus.c.
|
static |
Definition at line 897 of file test_res_prometheus.c.
Definition at line 42 of file test_res_prometheus.c.
|
static |
Definition at line 40 of file test_res_prometheus.c.
Referenced by get_curl_instance(), and process_config().