67 std::chrono::milliseconds
window = std::chrono::seconds(5));
80 void record(
const std::string &topic,
size_t bytes,
81 std::string sample = std::string(),
82 std::chrono::steady_clock::time_point now =
83 std::chrono::steady_clock::now());
95 std::vector<TopicStat>
snapshot(std::chrono::steady_clock::time_point now =
96 std::chrono::steady_clock::now())
const;
100 std::chrono::milliseconds
window()
const;
111 std::deque<std::pair<std::chrono::steady_clock::time_point, size_t>>
113 size_t total_messages = 0;
114 std::chrono::steady_clock::time_point last_seen{};
115 size_t last_size = 0;
116 std::string last_sample;
119 mutable std::mutex _mtx;
120 std::chrono::milliseconds _window;
123 std::map<std::string, Entry> _entries;
Thread-safe sliding-window aggregator of per-topic msg/s and bytes/s, fed by record() and read back v...
void set_window(std::chrono::milliseconds window)
Changes the trailing window used by future record()/snapshot() calls.
std::vector< TopicStat > snapshot(std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now()) const
Snapshot of every topic seen so far, as of now.
void record(const std::string &topic, size_t bytes, std::string sample=std::string(), std::chrono::steady_clock::time_point now=std::chrono::steady_clock::now())
Records one observed message for topic.
std::chrono::milliseconds window() const
TopicStats(std::chrono::milliseconds window=std::chrono::seconds(5))
Snapshot of one topic's aggregated activity, as computed by TopicStats::snapshot() at a given instant...
std::chrono::steady_clock::time_point last_seen
Wall-clock-independent instant of the most recent record() call.
double messages_per_second
size_t total_messages
Lifetime message count for this topic, never pruned by the window.