Skip to content

Commit

Permalink
fix: include next_run_at in the realtime triggers usage reporting (#3383
Browse files Browse the repository at this point in the history
)

Co-authored-by: Hengfei Yang <[email protected]>
  • Loading branch information
Subhra264 and hengfeiyang committed Apr 30, 2024
1 parent 10fb427 commit 30d06f1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/service/ingestion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ pub async fn evaluate_trigger(trigger: Option<TriggerAlertData>) {
&alert.stream_name,
&alert.name
);

let next_run_at = Utc::now().timestamp_micros()
+ Duration::try_minutes(alert.trigger_condition.silence)
.unwrap()
.num_microseconds()
.unwrap();
// After the notification is sent successfully, we need to update
// the silence period of the trigger
_ = db::scheduler::update_trigger(db::scheduler::Trigger {
Expand All @@ -232,14 +238,11 @@ pub async fn evaluate_trigger(trigger: Option<TriggerAlertData>) {
module_key,
is_silenced: true,
is_realtime: true,
next_run_at: Utc::now().timestamp_micros()
+ Duration::try_minutes(alert.trigger_condition.silence)
.unwrap()
.num_microseconds()
.unwrap(),
next_run_at,
..Default::default()
})
.await;
trigger_data_stream.next_run_at = next_run_at;
}
trigger_data_stream.end_time = Utc::now().timestamp_micros();
// Let all the alerts send notifications first
Expand Down

0 comments on commit 30d06f1

Please sign in to comment.