@@ -155,7 +155,7 @@ func (i *Incident) ProcessEvent(ctx context.Context, ev *event.Event, created bo
155155 }
156156
157157 // Re-evaluate escalations based on the newly evaluated rules.
158- escalations , err := i .evaluateEscalations (ev . Time )
158+ escalations , err := i .evaluateEscalations (ev )
159159 if err != nil {
160160 return err
161161 }
@@ -196,7 +196,7 @@ func (i *Incident) RetriggerEscalations(ev *event.Event) {
196196 return
197197 }
198198
199- escalations , err := i .evaluateEscalations (ev . Time )
199+ escalations , err := i .evaluateEscalations (ev )
200200 if err != nil {
201201 i .logger .Errorw ("Reevaluating time-based escalations failed" , zap .Error (err ))
202202 return
@@ -393,7 +393,7 @@ func (i *Incident) evaluateRules(ctx context.Context, tx *sqlx.Tx, eventID int64
393393
394394// evaluateEscalations evaluates this incidents rule escalations to be triggered if they aren't already.
395395// Returns the newly evaluated escalations to be triggered or an error on database failure.
396- func (i * Incident ) evaluateEscalations (eventTime time. Time ) ([]* rule.Escalation , error ) {
396+ func (i * Incident ) evaluateEscalations (e * event. Event ) ([]* rule.Escalation , error ) {
397397 if i .EscalationState == nil {
398398 i .EscalationState = make (map [int64 ]* EscalationState )
399399 }
@@ -406,7 +406,7 @@ func (i *Incident) evaluateEscalations(eventTime time.Time) ([]*rule.Escalation,
406406 i .timer = nil
407407 }
408408
409- filterContext := & rule.EscalationFilter {IncidentAge : eventTime .Sub (i .StartedAt ), IncidentSeverity : i .Severity }
409+ filterContext := & rule.EscalationFilter {IncidentAge : e . Time .Sub (i .StartedAt ), IncidentSeverity : i .Severity }
410410
411411 var escalations []* rule.Escalation
412412 retryAfter := rule .RetryNever
@@ -453,16 +453,17 @@ func (i *Incident) evaluateEscalations(eventTime time.Time) ([]*rule.Escalation,
453453 // i.e. if an incident is 15m old and an escalation rule evaluates incident_age>=1h the retryAfter would
454454 // contain 45m (1h - incident age (15m)). Therefore, we have to use the event time instead of the incident
455455 // start time here.
456- nextEvalAt := eventTime .Add (retryAfter )
456+ nextEvalAt := e . Time .Add (retryAfter )
457457
458458 i .logger .Infow ("Scheduling escalation reevaluation" , zap .Duration ("after" , retryAfter ), zap .Time ("at" , nextEvalAt ))
459459 i .timer = time .AfterFunc (retryAfter , func () {
460460 i .logger .Info ("Reevaluating escalations" )
461461
462462 i .RetriggerEscalations (& event.Event {
463- Type : event .TypeInternal ,
464- Time : nextEvalAt ,
465- Message : fmt .Sprintf ("Incident reached age %v" , nextEvalAt .Sub (i .StartedAt )),
463+ Type : event .TypeInternal ,
464+ Time : nextEvalAt ,
465+ Severity : e .Severity ,
466+ Message : fmt .Sprintf ("Incident reached age %v" , nextEvalAt .Sub (i .StartedAt )),
466467 })
467468 })
468469 }
0 commit comments