Simplify service recovery notification logic
- Remove bloated last_meaningful_status tracking - Treat any Unknown→Ok transition as recovery - Reduce JSON persistence to only metric_statuses and metric_details - Eliminate unnecessary status history complexity
This commit is contained in:
parent
00a8ed3da2
commit
049ac53629
@ -73,6 +73,7 @@ impl NotificationManager {
|
||||
.copied()
|
||||
.unwrap_or(Status::Unknown);
|
||||
|
||||
|
||||
// Check if status actually changed
|
||||
if old_status != new_status {
|
||||
// Update stored status only on change
|
||||
@ -114,7 +115,7 @@ impl NotificationManager {
|
||||
// Only notify on transitions to warning/critical, or recovery to ok
|
||||
let should_send = match (status_change.old_status, status_change.new_status) {
|
||||
(_, Status::Warning) | (_, Status::Critical) => true,
|
||||
(Status::Warning | Status::Critical, Status::Ok) => true,
|
||||
(Status::Warning | Status::Critical | Status::Unknown, Status::Ok) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
@ -136,8 +137,9 @@ impl NotificationManager {
|
||||
status_change.details = Some(self.format_metric_details(metric));
|
||||
|
||||
// For recovery notifications, include original problem details
|
||||
if status_change.new_status == Status::Ok &&
|
||||
(status_change.old_status == Status::Warning || status_change.old_status == Status::Critical) {
|
||||
let is_recovery = status_change.new_status == Status::Ok;
|
||||
|
||||
if is_recovery {
|
||||
if let Some(old_details) = self.metric_details.get(&status_change.metric_name) {
|
||||
status_change.details = Some(format!(
|
||||
"Recovered from: {}\nCurrent status: {}",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user