Skip to content

Consider log API to log once N events have happened #170

Description

@fisherdarling

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:

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
    ),
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions