Fixed window rate limiter for logging.
More...
#include <logging.h>
|
| struct | Stats |
| | Keeps track of an individual source location and how many available bytes are left for logging from it. More...
|
| |
Fixed window rate limiter for logging.
Definition at line 113 of file logging.h.
◆ SchedulerFunction
◆ Status
Suppression status of a source log location.
| Enumerator |
|---|
| UNSUPPRESSED | |
| NEWLY_SUPPRESSED | |
| STILL_SUPPRESSED | |
Definition at line 156 of file logging.h.
◆ LogRateLimiter()
| BCLog::LogRateLimiter::LogRateLimiter |
( |
uint64_t |
max_bytes, |
|
|
std::chrono::seconds |
reset_window |
|
) |
| |
|
private |
◆ Consume()
Consumes source_loc's available bytes corresponding to the size of the (formatted) str and returns its status.
Definition at line 389 of file logging.cpp.
◆ Create()
- Parameters
-
| scheduler_func | Callable object used to schedule resetting the window. The first parameter is the function to be executed, and the second is the reset_window interval. |
| max_bytes | Maximum number of bytes that can be logged for each source location. |
| reset_window | Time window after which the stats are reset. |
Definition at line 377 of file logging.cpp.
◆ GUARDED_BY()
Stats for each source location that has attempted to log something.
◆ Reset()
| void BCLog::LogRateLimiter::Reset |
( |
| ) |
|
Resets all usage to zero. Called periodically by the scheduler.
Definition at line 553 of file logging.cpp.
◆ SuppressionsActive()
| bool BCLog::LogRateLimiter::SuppressionsActive |
( |
| ) |
const |
|
inline |
Returns true if any log locations are currently being suppressed.
Definition at line 169 of file logging.h.
◆ m_max_bytes
| const uint64_t BCLog::LogRateLimiter::m_max_bytes |
Maximum number of bytes logged per location per window.
Definition at line 152 of file logging.h.
◆ m_mutex
◆ m_reset_window
| const std::chrono::seconds BCLog::LogRateLimiter::m_reset_window |
Interval after which the window is reset.
Definition at line 154 of file logging.h.
◆ m_suppression_active
| std::atomic<bool> BCLog::LogRateLimiter::m_suppression_active {false} |
|
private |
Whether any log locations are suppressed. Cached view on m_source_locations for performance reasons.
Definition at line 134 of file logging.h.
The documentation for this class was generated from the following files: