1
0
mirror of https://github.com/coturn/coturn.git synced 2025-10-27 13:00:59 +01:00

Reduce ifdefs in code: TURN_NO_PROMETHEUS (#1116)

TURN_NO_PROMETHEUS define is used in minimal amount of places now
This commit is contained in:
Pavel Punsky 2023-11-05 17:49:03 -08:00 committed by GitHub
parent 4bc872b663
commit 99cc8aaa65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View File

@ -3572,12 +3572,10 @@ void turn_report_allocation_set(void *a, turn_time_t lifetime, int refresh) {
(unsigned long)lifetime, type, saddr, rsaddr, ssl, cipher);
}
#endif
#if !defined(TURN_NO_PROMETHEUS)
{
if (!refresh)
prom_inc_allocation(get_ioa_socket_type(ss->client_socket));
}
#endif
}
}
}
@ -3631,7 +3629,6 @@ void turn_report_allocation_delete(void *a, SOCKET_TYPE socket_type) {
(unsigned long)(ss->t_peer_sent_bytes));
}
#endif
#if !defined(TURN_NO_PROMETHEUS)
{
if (ss->realm_options.name[0]) {
@ -3655,7 +3652,6 @@ void turn_report_allocation_delete(void *a, SOCKET_TYPE socket_type) {
}
prom_dec_allocation(socket_type);
}
#endif
}
}
}

View File

@ -203,4 +203,19 @@ void start_prometheus_server(void) {
return;
}
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) {
UNUSED_ARG(realm);
UNUSED_ARG(user);
UNUSED_ARG(rsvp);
UNUSED_ARG(rsvb);
UNUSED_ARG(sentp);
UNUSED_ARG(sentb);
UNUSED_ARG(peer);
}
void prom_inc_allocation(SOCKET_TYPE type) { UNUSED_ARG(type); }
void prom_dec_allocation(SOCKET_TYPE type) { UNUSED_ARG(type); }
#endif /* TURN_NO_PROMETHEUS */

View File

@ -2,18 +2,17 @@
#ifndef __PROM_SERVER_H__
#define __PROM_SERVER_H__
#include "ns_turn_ioalib.h"
#include <stdbool.h>
#define DEFAULT_PROM_SERVER_PORT (9641)
#define TURN_ALLOC_STR_MAX_SIZE (20)
#if !defined(TURN_NO_PROMETHEUS)
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "ns_turn_ioalib.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -54,8 +53,6 @@ extern prom_counter_t *turn_total_traffic_peer_sentb;
extern prom_gauge_t *turn_total_allocations_number;
#define TURN_ALLOC_STR_MAX_SIZE (20)
#ifdef __cplusplus
extern "C" {
#endif
@ -76,6 +73,12 @@ void prom_inc_stun_binding_error(void);
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);
void prom_inc_allocation(SOCKET_TYPE type);
void prom_dec_allocation(SOCKET_TYPE type);
#endif /* TURN_NO_PROMETHEUS */
#ifdef __cplusplus