stasis: Add statistics gathering in developer mode.

This change adds statistics gathering to Stasis topics,
subscriptions, and message types. These can be viewed using
CLI commands and provide insight into how Stasis is used
and how long certain operations take to execute.

These are only available when Asterisk is compiled in
developer mode and do not have any impact under normal
operation.

ASTERISK-28117

Change-Id: I94411b53767f89ee01714daaecf0c2f1666e863f
This commit is contained in:
Joshua C. Colp
2018-11-30 07:40:40 -04:00
parent 1f8062c6a6
commit fe07093660
8 changed files with 848 additions and 14 deletions

View File

@@ -204,8 +204,14 @@ static void router_dispatch(void *data,
}
}
#ifdef AST_DEVMODE
static struct stasis_message_router *stasis_message_router_create_internal(
struct stasis_topic *topic, int use_thread_pool, const char *file, int lineno,
const char *func)
#else
static struct stasis_message_router *stasis_message_router_create_internal(
struct stasis_topic *topic, int use_thread_pool)
#endif
{
int res;
struct stasis_message_router *router;
@@ -224,11 +230,20 @@ static struct stasis_message_router *stasis_message_router_create_internal(
return NULL;
}
#ifdef AST_DEVMODE
if (use_thread_pool) {
router->subscription = __stasis_subscribe_pool(topic, router_dispatch, router, file, lineno, func);
} else {
router->subscription = __stasis_subscribe(topic, router_dispatch, router, file, lineno, func);
}
#else
if (use_thread_pool) {
router->subscription = stasis_subscribe_pool(topic, router_dispatch, router);
} else {
router->subscription = stasis_subscribe(topic, router_dispatch, router);
}
#endif
if (!router->subscription) {
ao2_ref(router, -1);
@@ -241,17 +256,33 @@ static struct stasis_message_router *stasis_message_router_create_internal(
return router;
}
#ifdef AST_DEVMODE
struct stasis_message_router *__stasis_message_router_create(
struct stasis_topic *topic, const char *file, int lineno, const char *func)
{
return stasis_message_router_create_internal(topic, 0, file, lineno, func);
}
#else
struct stasis_message_router *stasis_message_router_create(
struct stasis_topic *topic)
{
return stasis_message_router_create_internal(topic, 0);
}
#endif
#ifdef AST_DEVMODE
struct stasis_message_router *__stasis_message_router_create_pool(
struct stasis_topic *topic, const char *file, int lineno, const char *func)
{
return stasis_message_router_create_internal(topic, 1, file, lineno, func);
}
#else
struct stasis_message_router *stasis_message_router_create_pool(
struct stasis_topic *topic)
{
return stasis_message_router_create_internal(topic, 1);
}
#endif
void stasis_message_router_unsubscribe(struct stasis_message_router *router)
{