res_prometheus: Add Asterisk channel metrics

This patch adds basic Asterisk channel statistics to the res_prometheus
module. This includes:

* asterisk_calls_sum: A running sum of the total number of
  processed calls

* asterisk_calls_count: The current number of calls

* asterisk_channels_count: The current number of channels

* asterisk_channels_state: The state of any particular channel

* asterisk_channels_duration_seconds: How long a channel has existed,
  in seconds

In all cases, enough information is provided with each channel metric
to determine a unique instance of Asterisk that provided the data, as
well as the name, type, unique ID, and - if present - linked ID of each
channel.

ASTERISK-28403

Change-Id: I0db306ec94205d4f58d1e7fbabfe04b185869f59
This commit is contained in:
Matt Jordan
2019-05-02 19:45:27 -05:00
parent 54f7f7dc20
commit 0760af71ad
7 changed files with 371 additions and 11 deletions

View File

@@ -83,6 +83,36 @@ struct prometheus_general_config {
);
};
/*!
* \brief A function table for a metrics provider
*
* \details
* It's generally nice to separate out things that provide metrics
* from the core of this module. For those that want to be notified
* when things happen in the core module, they can provide an instance
* of this function table using \c prometheus_metrics_provider_register
* and be notified when module affecting changes occur.
*/
struct prometheus_metrics_provider {
/*!
* \brief Handy name of the provider for debugging purposes
*/
const char *name;
/*!
* \brief Reload callback
*
* \param config The reloaded config
*
* \retval 0 success
* \retval -1 error
*/
int (* const reload_cb)(struct prometheus_general_config *config);
/*!
* \brief Unload callback.
*/
void (* const unload_cb)(void);
};
/*!
* \brief Prometheus metric type
*
@@ -437,6 +467,13 @@ int prometheus_callback_register(struct prometheus_callback *callback);
*/
void prometheus_callback_unregister(struct prometheus_callback *callback);
/*!
* \brief Register a metrics provider
*
* \param provider The provider function table to register
*/
void prometheus_metrics_provider_register(const struct prometheus_metrics_provider *provider);
/*!
* \brief Retrieve the current configuration of the module
*