macro_rules! insert_and_log_throttled {
(
$level:expr,
target: $target:expr,
log_interval: $log_interval:expr,
prefix: $prefix:expr,
$stats:expr,
$value:expr
) => { ... };
(
$level:expr,
target: $target:expr,
prefix: $prefix:expr,
$stats:expr,
$value:expr
) => { ... };
}
Expand description
Inserts a value into a SlidingStats
and conditionally logs the current stats using tracing
.
This macro inserts the given $value
into the $stats
collector only if tracing is enabled
for the given $target
and $level
. The log will be emiited only if enough time has passed
since the last logged output (as tracked by the internal last_log timestamp).
The macro respects throttling: stats will not be logged more frequently than either the
explicitly provided log_interval
or the stats’ retention period (if no interval is given).
Note that:
- Logging is skipped unless
tracing::enabled!
returns true for the target and level. - All entries older than the retention period will be logged and pruned,
- The newly inserted value may not be included in the logged statistics output (it is inserted after the log decision).