Asterisk - The Open Source Telephony Project GIT-master-2de1a68
Functions | Variables
pjsip_outbound_registrations.c File Reference

Prometheus PJSIP Outbound Registration Metrics. More...

#include "asterisk.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/stasis_system.h"
#include "asterisk/res_prometheus.h"
#include "prometheus_internal.h"
Include dependency graph for pjsip_outbound_registrations.c:

Go to the source code of this file.

Functions

int pjsip_outbound_registration_metrics_init (void)
 Initialize PJSIP outbound registration metrics. More...
 
static void pjsip_outbound_registration_metrics_unload_cb (void)
 

Variables

static struct prometheus_metrics_provider provider
 

Detailed Description

Prometheus PJSIP Outbound Registration Metrics.

Author
Matt Jordan mjord.nosp@m.an@d.nosp@m.igium.nosp@m..com

Definition in file pjsip_outbound_registrations.c.

Function Documentation

◆ pjsip_outbound_registration_metrics_init()

int pjsip_outbound_registration_metrics_init ( void  )

Initialize PJSIP outbound registration metrics.

Return values
0success
-1error

Definition at line 342 of file pjsip_outbound_registrations.c.

343{
345
346#ifdef HAVE_PJPROJECT
348 if (!router) {
349 goto cleanup;
350 }
351
352 if (stasis_message_router_add(router, ast_system_registry_type(), registry_message_cb, NULL)) {
353 goto cleanup;
354 }
355
357 goto cleanup;
358 }
359
361 goto cleanup;
362 }
363#endif /* HAVE_PJPROJECT */
364 return 0;
365
366#ifdef HAVE_PJPROJECT
367cleanup:
369 router = NULL;
372
373 return -1;
374#endif /* HAVE_PJPROJECT */
375}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
static void * cleanup(void *unused)
Definition: pbx_realtime.c:124
static struct prometheus_metrics_provider provider
static struct stasis_message_router * router
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static const struct ast_sorcery_instance_observer observer_callbacks_registrations
static const struct ast_sorcery_observer registration_observer
void prometheus_metrics_provider_register(const struct prometheus_metrics_provider *provider)
Register a metrics provider.
#define NULL
Definition: resample.c:96
void ast_sorcery_observer_remove(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Remove an observer from a specific object type.
Definition: sorcery.c:2418
void ast_sorcery_instance_observer_remove(struct ast_sorcery *sorcery, const struct ast_sorcery_instance_observer *callbacks)
Remove an observer from a sorcery instance.
Definition: sorcery.c:537
int ast_sorcery_observer_add(const struct ast_sorcery *sorcery, const char *type, const struct ast_sorcery_observer *callbacks)
Add an observer to a specific object type.
Definition: sorcery.c:2386
int ast_sorcery_instance_observer_add(struct ast_sorcery *sorcery, const struct ast_sorcery_instance_observer *callbacks)
Add an observer to a sorcery instance.
Definition: sorcery.c:520
#define stasis_message_router_create(topic)
Create a new message router object.
int stasis_message_router_add(struct stasis_message_router *router, struct stasis_message_type *message_type, stasis_subscription_cb callback, void *data)
Add a route to a message router.
struct stasis_message_type * ast_system_registry_type(void)
A stasis_message_type for outbound registration.
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes.

References ao2_cleanup, ast_sip_get_sorcery(), ast_sorcery_instance_observer_add(), ast_sorcery_instance_observer_remove(), ast_sorcery_observer_add(), ast_sorcery_observer_remove(), ast_system_registry_type(), ast_system_topic(), cleanup(), NULL, observer_callbacks_registrations, prometheus_metrics_provider_register(), provider, registration_observer, router, stasis_message_router_add(), and stasis_message_router_create.

Referenced by load_module().

◆ pjsip_outbound_registration_metrics_unload_cb()

static void pjsip_outbound_registration_metrics_unload_cb ( void  )
static

Definition at line 323 of file pjsip_outbound_registrations.c.

324{
325#ifdef HAVE_PJPROJECT
327 router = NULL;
330#endif /* HAVE_PJPROJECT */
331}
void stasis_message_router_unsubscribe_and_join(struct stasis_message_router *router)
Unsubscribe the router from the upstream topic, blocking until the final message has been processed.

References ast_sip_get_sorcery(), ast_sorcery_instance_observer_remove(), ast_sorcery_observer_remove(), NULL, observer_callbacks_registrations, registration_observer, router, and stasis_message_router_unsubscribe_and_join().

Variable Documentation

◆ provider

struct prometheus_metrics_provider provider
static
Initial value:
= {
.name = "pjsip_outbound_registration",
}
static void pjsip_outbound_registration_metrics_unload_cb(void)

Definition at line 337 of file pjsip_outbound_registrations.c.

Referenced by pjsip_outbound_registration_metrics_init().