cloudflare / cloudflare/foundations
Consider log API to log once N events have happened
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 133
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 11
Description
This is kind of like the inverse of ratelimiting. The idea here, is only if a codepath is triggered enough times in a given time window is the log fired.
Example from Oxy:
```rust
consecutive_failed_msg_write_attempts += 1;
match consecutive_failed_msg_write_attempts {
0..=2 => log::debug!(
"could not write log object to unix stream socket, will retry";
"socket_file" => unix_socket_path.clone(),
"task_name" => &task_name,
"error" => e.to_string(),
"consecutive_failures" => consecutive_failed_msg_write_attempts
),
3.. => log::warn!(
"could not write log object to unix stream socket, will retry";
"socket_file" => unix_socket_path.clone(),
"task_name" => &task_name,
"error" => e.to_string(),
"consecutive_failures" => consecutive_failed_msg_write_attempts
),
};
```
Contributor guide
Assessment
This issue has not been assessed yet.