Base class for rate-limiting a log (slow query log etc.)
More...
#include <log.h>
|
static const ulong | LOG_THROTTLE_WINDOW_SIZE = 60000000 |
| We're rate-limiting messages per minute; 60,000,000 microsecs = 60s Debugging is less tedious with a window in the region of 5000000. More...
|
|
Base class for rate-limiting a log (slow query log etc.)
◆ Log_throttle()
Log_throttle::Log_throttle |
( |
ulong |
window_usecs, |
|
|
const char * |
msg |
|
) |
| |
|
inlineprotected |
- Parameters
-
window_usecs | ... in this many micro-seconds |
msg | use this template containing lu as only non-literal |
◆ in_window()
bool Log_throttle::in_window |
( |
ulonglong |
now | ) |
const |
|
inlineprotected |
Check whether we're still in the current window.
(If not, the caller will want to print a summary (if the logging of any lines was suppressed), and start a new window.)
◆ inc_log_count()
bool Log_throttle::inc_log_count |
( |
ulong |
rate | ) |
|
|
inlineprotected |
Increase count of logs we're handling.
- Parameters
-
rate | Limit on records to be logged during the throttling window. |
- Return values
-
true | - log rate limit is exceeded, so record should be suppressed. |
false | - log rate limit is not exceeded, record should be logged. |
◆ new_window()
void Log_throttle::new_window |
( |
ulonglong |
now | ) |
|
|
protected |
◆ prepare_summary()
ulong Log_throttle::prepare_summary |
( |
ulong |
rate | ) |
|
|
protected |
Prepare a summary of suppressed lines for logging.
This function returns the number of queries that were qualified for inclusion in the log, but were not printed because of the rate-limiting. The summary will contain this count as well as the respective totals for lock and execution time. This function assumes that the caller already holds the necessary locks.
- Parameters
-
rate | Limit on records logged during the throttling window. |
◆ count
ulong Log_throttle::count |
|
private |
There have been this many lines of this type in this window, including those that we suppressed.
(We don't simply stop counting once we reach the threshold as we'll write a summary of the suppressed lines later.)
◆ LOG_THROTTLE_WINDOW_SIZE
const ulong Log_throttle::LOG_THROTTLE_WINDOW_SIZE = 60000000 |
|
static |
We're rate-limiting messages per minute; 60,000,000 microsecs = 60s Debugging is less tedious with a window in the region of 5000000.
◆ summary_template
const char* Log_throttle::summary_template |
|
protected |
Template for the summary line.
Should contain lu as the only conversion specification.
◆ window_end
When will/did current window end?
◆ window_size
const ulong Log_throttle::window_size |
|
private |
Log no more than rate lines of a given type per window_size (e.g.
per minute, usually LOG_THROTTLE_WINDOW_SIZE).
The documentation for this class was generated from the following files: