High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::logger::rate_limit Class Reference

Detailed Description

Apply a rate limit to log message(s)

Pass this to logger::log() to apply a rate limit to the message. The rate limit is applied to all logger::log() calls this rate limit is passed to. Example:

void handle_request() {
    static thread_local logger::rate_limit my_rl(std::chrono::seconds(10));
    // ...
    my_log.log(log_level::info, my_rl, "a message we don't want to log on every request, only at most once each 10 seconds");
    // ...

The rate limit ensures that at most one message per interval will be logged. If there were messages dropped due to rate-limiting the following snippet will be prepended to the first non-dropped log messages:

(rate limiting dropped $N similar messages)

Where $N is the number of messages dropped.

#include <seastar/util/log.hh>

Public Member Functions

 rate_limit (std::chrono::milliseconds interval)

The documentation for this class was generated from the following file: