master
h 38 lines 969 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_ND_LOG_LIMIT_H
4 #define NETDATA_ND_LOG_LIMIT_H
5
6 #include "../libnetdata.h"
7
8 struct nd_log_source;
9 bool nd_log_limit_reached(struct nd_log_source *source);
10
11 struct nd_log_limit {
12 SPINLOCK spinlock;
13 usec_t started_monotonic_ut;
14 uint32_t counter;
15 uint32_t prevented;
16
17 uint32_t throttle_period;
18 uint32_t logs_per_period;
19 uint32_t logs_per_period_backup;
20 };
21
22 #define ND_LOG_LIMITS_DEFAULT (struct nd_log_limit){ \
23 .spinlock = SPINLOCK_INITIALIZER, \
24 .logs_per_period = ND_LOG_DEFAULT_THROTTLE_LOGS, \
25 .logs_per_period_backup = ND_LOG_DEFAULT_THROTTLE_LOGS, \
26 .throttle_period = ND_LOG_DEFAULT_THROTTLE_PERIOD, \
27 }
28
29 #define ND_LOG_LIMITS_UNLIMITED (struct nd_log_limit){ \
30 .spinlock = SPINLOCK_INITIALIZER, \
31 .logs_per_period = 0, \
32 .logs_per_period_backup = 0, \
33 .throttle_period = 0, \
34 }
35
36 #include "nd_log-internals.h"
37
38 #endif //NETDATA_ND_LOG_LIMIT_H