Use bool to enable prometheus (#1779)
`turn_params.prometheus` is bool but used as int throughout the code `turn_params,prometheus_username_labels` is bool but in one place is set with 1 This PR changes 0 and 1 to false and true accordingly
This commit is contained in:
parent
a668d4b4cc
commit
265d1029e6
1
.gitignore
vendored
1
.gitignore
vendored
@ -83,3 +83,4 @@ Thumbs.db
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
.cache/*
|
||||
|
||||
@ -2214,7 +2214,7 @@ static void set_option(int c, char *value) {
|
||||
break;
|
||||
#endif
|
||||
case PROMETHEUS_OPT:
|
||||
turn_params.prometheus = 1;
|
||||
turn_params.prometheus = true;
|
||||
break;
|
||||
case PROMETHEUS_PORT_OPT:
|
||||
turn_params.prometheus_port = atoi(value);
|
||||
@ -2226,7 +2226,7 @@ static void set_option(int c, char *value) {
|
||||
STRCPY(turn_params.prometheus_path, value);
|
||||
break;
|
||||
case PROMETHEUS_ENABLE_USERNAMES_OPT:
|
||||
turn_params.prometheus_username_labels = 1;
|
||||
turn_params.prometheus_username_labels = true;
|
||||
break;
|
||||
case AUTH_SECRET_OPT:
|
||||
turn_params.use_auth_secret_with_timestamp = 1;
|
||||
|
||||
@ -112,7 +112,7 @@ MHD_RESULT promhttp_handler(void *cls, struct MHD_Connection *connection, const
|
||||
}
|
||||
|
||||
void start_prometheus_server(void) {
|
||||
if (turn_params.prometheus == 0) {
|
||||
if (!turn_params.prometheus) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "prometheus collector disabled, not started\n");
|
||||
return;
|
||||
}
|
||||
@ -238,7 +238,7 @@ void start_prometheus_server(void) {
|
||||
|
||||
void prom_set_finished_traffic(const char *realm, const char *user, unsigned long rsvp, unsigned long rsvb,
|
||||
unsigned long sentp, unsigned long sentb, bool peer) {
|
||||
if (turn_params.prometheus == 1) {
|
||||
if (turn_params.prometheus) {
|
||||
|
||||
const char *label[] = {realm, NULL};
|
||||
if (turn_params.prometheus_username_labels) {
|
||||
@ -270,33 +270,33 @@ void prom_set_finished_traffic(const char *realm, const char *user, unsigned lon
|
||||
}
|
||||
|
||||
void prom_inc_allocation(SOCKET_TYPE type) {
|
||||
if (turn_params.prometheus == 1) {
|
||||
if (turn_params.prometheus) {
|
||||
const char *label[] = {socket_type_name(type)};
|
||||
prom_gauge_inc(turn_total_allocations, label);
|
||||
}
|
||||
}
|
||||
|
||||
void prom_dec_allocation(SOCKET_TYPE type) {
|
||||
if (turn_params.prometheus == 1) {
|
||||
if (turn_params.prometheus) {
|
||||
const char *label[] = {socket_type_name(type)};
|
||||
prom_gauge_dec(turn_total_allocations, label);
|
||||
}
|
||||
}
|
||||
|
||||
void prom_inc_stun_binding_request(void) {
|
||||
if (turn_params.prometheus == 1) {
|
||||
if (turn_params.prometheus) {
|
||||
prom_counter_add(stun_binding_request, 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void prom_inc_stun_binding_response(void) {
|
||||
if (turn_params.prometheus == 1) {
|
||||
if (turn_params.prometheus) {
|
||||
prom_counter_add(stun_binding_response, 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void prom_inc_stun_binding_error(void) {
|
||||
if (turn_params.prometheus == 1) {
|
||||
if (turn_params.prometheus) {
|
||||
prom_counter_add(stun_binding_error, 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user