|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Tracks cooldown periods for alert notifications. More...
#include <alert_pipeline.h>
Public Member Functions | |
| cooldown_tracker (std::chrono::milliseconds default_cooldown) | |
| Set default cooldown period. | |
| bool | is_in_cooldown (const std::string &fingerprint) const |
| Check if alert is in cooldown. | |
| void | record_notification (const std::string &fingerprint) |
| Record notification time. | |
| void | set_cooldown (const std::string &fingerprint, std::chrono::milliseconds cooldown) |
| Set custom cooldown for specific alert. | |
| std::chrono::milliseconds | remaining_cooldown (const std::string &fingerprint) const |
| Get time remaining in cooldown. | |
| void | clear_cooldown (const std::string &fingerprint) |
| Clear cooldown state for an alert. | |
| void | reset () |
| Clear all cooldown state. | |
Private Member Functions | |
| std::chrono::milliseconds | get_cooldown_for (const std::string &fingerprint) const |
Private Attributes | |
| std::chrono::milliseconds | default_cooldown_ |
| std::mutex | mutex_ |
| std::unordered_map< std::string, std::chrono::steady_clock::time_point > | last_notification_ |
| std::unordered_map< std::string, std::chrono::milliseconds > | custom_cooldowns_ |
Tracks cooldown periods for alert notifications.
Prevents notification spam by enforcing minimum intervals between notifications for the same alert.
Definition at line 403 of file alert_pipeline.h.
|
inlineexplicit |
Set default cooldown period.
Definition at line 408 of file alert_pipeline.h.
|
inline |
Clear cooldown state for an alert.
Definition at line 476 of file alert_pipeline.h.
References last_notification_, and mutex_.
|
inlineprivate |
Definition at line 490 of file alert_pipeline.h.
References custom_cooldowns_, and default_cooldown_.
Referenced by is_in_cooldown(), and remaining_cooldown().
|
inline |
Check if alert is in cooldown.
| fingerprint | Alert fingerprint |
Definition at line 416 of file alert_pipeline.h.
References get_cooldown_for(), last_notification_, and mutex_.
Referenced by main().
|
inline |
Record notification time.
| fingerprint | Alert fingerprint |
Definition at line 433 of file alert_pipeline.h.
References last_notification_, and mutex_.
Referenced by main().
|
inline |
Get time remaining in cooldown.
| fingerprint | Alert fingerprint |
Definition at line 454 of file alert_pipeline.h.
References get_cooldown_for(), last_notification_, and mutex_.
Referenced by main().
|
inline |
Clear all cooldown state.
Definition at line 484 of file alert_pipeline.h.
References last_notification_, and mutex_.
Referenced by main().
|
inline |
Set custom cooldown for specific alert.
| fingerprint | Alert fingerprint |
| cooldown | Custom cooldown duration |
Definition at line 443 of file alert_pipeline.h.
References custom_cooldowns_, and mutex_.
Referenced by main().
|
private |
Definition at line 501 of file alert_pipeline.h.
Referenced by get_cooldown_for(), and set_cooldown().
|
private |
Definition at line 498 of file alert_pipeline.h.
Referenced by get_cooldown_for().
|
private |
Definition at line 500 of file alert_pipeline.h.
Referenced by clear_cooldown(), is_in_cooldown(), record_notification(), remaining_cooldown(), and reset().
|
mutableprivate |
Definition at line 499 of file alert_pipeline.h.
Referenced by clear_cooldown(), is_in_cooldown(), record_notification(), remaining_cooldown(), reset(), and set_cooldown().