Add STUN request/response/error prometheus counters (#1115)
Somewhat relevant to #1075
This commit is contained in:
parent
902cb99849
commit
7038763627
@ -3514,6 +3514,28 @@ const char *get_ioa_socket_ssl_method(ioa_socket_handle s) {
|
|||||||
return "no SSL";
|
return "no SSL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stun_report_binding(void *a, STUN_PROMETHEUS_METRIC_TYPE type) {
|
||||||
|
#if !defined(TURN_NO_PROMETHEUS)
|
||||||
|
UNUSED_ARG(a);
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
prom_inc_stun_binding_request();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
prom_inc_stun_binding_response();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
prom_inc_stun_binding_error();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
UNUSED_ARG(a);
|
||||||
|
UNUSED_ARG(type);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void turn_report_allocation_set(void *a, turn_time_t lifetime, int refresh) {
|
void turn_report_allocation_set(void *a, turn_time_t lifetime, int refresh) {
|
||||||
if (a) {
|
if (a) {
|
||||||
ts_ur_super_session *ss = (ts_ur_super_session *)(((allocation *)a)->owner);
|
ts_ur_super_session *ss = (ts_ur_super_session *)(((allocation *)a)->owner);
|
||||||
|
|||||||
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
#if !defined(TURN_NO_PROMETHEUS)
|
#if !defined(TURN_NO_PROMETHEUS)
|
||||||
|
|
||||||
|
prom_counter_t *stun_binding_request;
|
||||||
|
prom_counter_t *stun_binding_response;
|
||||||
|
prom_counter_t *stun_binding_error;
|
||||||
|
|
||||||
prom_counter_t *turn_traffic_rcvp;
|
prom_counter_t *turn_traffic_rcvp;
|
||||||
prom_counter_t *turn_traffic_rcvb;
|
prom_counter_t *turn_traffic_rcvb;
|
||||||
prom_counter_t *turn_traffic_sentp;
|
prom_counter_t *turn_traffic_sentp;
|
||||||
@ -41,7 +45,15 @@ void start_prometheus_server(void) {
|
|||||||
nlabels++;
|
nlabels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create traffic counter metrics
|
// Create STUN counters
|
||||||
|
stun_binding_request = prom_collector_registry_must_register_metric(
|
||||||
|
prom_counter_new("stun_binding_request", "Incoming STUN Binding requests", 0, NULL));
|
||||||
|
stun_binding_response = prom_collector_registry_must_register_metric(
|
||||||
|
prom_counter_new("stun_binding_response", "Outgoing STUN Binding responses", 0, NULL));
|
||||||
|
stun_binding_error = prom_collector_registry_must_register_metric(
|
||||||
|
prom_counter_new("stun_binding_error", "STUN Binding errors", 0, NULL));
|
||||||
|
|
||||||
|
// Create TURN traffic counter metrics
|
||||||
turn_traffic_rcvp = prom_collector_registry_must_register_metric(
|
turn_traffic_rcvp = prom_collector_registry_must_register_metric(
|
||||||
prom_counter_new("turn_traffic_rcvp", "Represents finished sessions received packets", nlabels, label));
|
prom_counter_new("turn_traffic_rcvp", "Represents finished sessions received packets", nlabels, label));
|
||||||
turn_traffic_rcvb = prom_collector_registry_must_register_metric(
|
turn_traffic_rcvb = prom_collector_registry_must_register_metric(
|
||||||
@ -160,6 +172,24 @@ void prom_dec_allocation(SOCKET_TYPE type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prom_inc_stun_binding_request(void) {
|
||||||
|
if (turn_params.prometheus == 1) {
|
||||||
|
prom_counter_add(stun_binding_request, 1, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void prom_inc_stun_binding_response(void) {
|
||||||
|
if (turn_params.prometheus == 1) {
|
||||||
|
prom_counter_add(stun_binding_response, 1, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void prom_inc_stun_binding_error(void) {
|
||||||
|
if (turn_params.prometheus == 1) {
|
||||||
|
prom_counter_add(stun_binding_error, 1, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void start_prometheus_server(void) {
|
void start_prometheus_server(void) {
|
||||||
|
|||||||
@ -24,6 +24,10 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif /* __clplusplus */
|
#endif /* __clplusplus */
|
||||||
|
|
||||||
|
extern prom_counter_t *stun_binding_request;
|
||||||
|
extern prom_counter_t *stun_binding_response;
|
||||||
|
extern prom_counter_t *stun_binding_error;
|
||||||
|
|
||||||
extern prom_counter_t *turn_new_allocation;
|
extern prom_counter_t *turn_new_allocation;
|
||||||
extern prom_counter_t *turn_refreshed_allocation;
|
extern prom_counter_t *turn_refreshed_allocation;
|
||||||
extern prom_counter_t *turn_deleted_allocation;
|
extern prom_counter_t *turn_deleted_allocation;
|
||||||
@ -63,6 +67,11 @@ void prom_set_finished_traffic(const char *realm, const char *user, unsigned lon
|
|||||||
|
|
||||||
void prom_inc_allocation(SOCKET_TYPE type);
|
void prom_inc_allocation(SOCKET_TYPE type);
|
||||||
void prom_dec_allocation(SOCKET_TYPE type);
|
void prom_dec_allocation(SOCKET_TYPE type);
|
||||||
|
|
||||||
|
void prom_inc_stun_binding_request(void);
|
||||||
|
void prom_inc_stun_binding_response(void);
|
||||||
|
void prom_inc_stun_binding_error(void);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void start_prometheus_server(void);
|
void start_prometheus_server(void);
|
||||||
|
|||||||
@ -205,6 +205,16 @@ void ioa_network_buffer_delete(ioa_engine_handle e, ioa_network_buffer_handle nb
|
|||||||
/*
|
/*
|
||||||
* Status reporting functions
|
* Status reporting functions
|
||||||
*/
|
*/
|
||||||
|
enum _STUN_PROMETHEUS_METRIC_TYPE {
|
||||||
|
STUN_PROMETHEUS_METRIC_TYPE_REQUEST,
|
||||||
|
STUN_PROMETHEUS_METRIC_TYPE_RESPONSE,
|
||||||
|
STUN_PROMETHEUS_METRIC_TYPE_ERROR,
|
||||||
|
STUN_PROMETHEUS_METRIC_TYPE_NUM
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum _STUN_PROMETHEUS_METRIC_TYPE STUN_PROMETHEUS_METRIC_TYPE;
|
||||||
|
void stun_report_binding(void *session, STUN_PROMETHEUS_METRIC_TYPE type);
|
||||||
|
|
||||||
void turn_report_allocation_set(void *a, turn_time_t lifetime, int refresh);
|
void turn_report_allocation_set(void *a, turn_time_t lifetime, int refresh);
|
||||||
void turn_report_allocation_delete(void *a, SOCKET_TYPE socket_type);
|
void turn_report_allocation_delete(void *a, SOCKET_TYPE socket_type);
|
||||||
void turn_report_session_usage(void *session, int force_invalid);
|
void turn_report_session_usage(void *session, int force_invalid);
|
||||||
|
|||||||
@ -2786,14 +2786,13 @@ static int handle_turn_binding(turn_turnserver *server, ts_ur_super_session *ss,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*ua_num > 0) {
|
if (*ua_num > 0) {
|
||||||
|
|
||||||
*err_code = 420;
|
*err_code = 420;
|
||||||
|
stun_report_binding(ss, STUN_PROMETHEUS_METRIC_TYPE_ERROR);
|
||||||
} else if (*err_code) {
|
} else if (*err_code) {
|
||||||
|
stun_report_binding(ss, STUN_PROMETHEUS_METRIC_TYPE_ERROR);
|
||||||
;
|
|
||||||
|
|
||||||
} else if (ss->client_socket && get_remote_addr_from_ioa_socket(ss->client_socket)) {
|
} else if (ss->client_socket && get_remote_addr_from_ioa_socket(ss->client_socket)) {
|
||||||
|
stun_report_binding(ss, STUN_PROMETHEUS_METRIC_TYPE_REQUEST);
|
||||||
|
|
||||||
size_t len = ioa_network_buffer_get_size(nbh);
|
size_t len = ioa_network_buffer_get_size(nbh);
|
||||||
if (stun_set_binding_response_str(ioa_network_buffer_data(nbh), &len, tid,
|
if (stun_set_binding_response_str(ioa_network_buffer_data(nbh), &len, tid,
|
||||||
@ -3737,7 +3736,7 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss,
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_turn_message_to(server, nbh, &response_origin, &response_destination);
|
send_turn_message_to(server, nbh, &response_origin, &response_destination);
|
||||||
|
stun_report_binding(ss, STUN_PROMETHEUS_METRIC_TYPE_RESPONSE);
|
||||||
no_response = 1;
|
no_response = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user