Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Add diagnostic logging for duplicate alert investigation (#70020)

Ngoc Khuat8f442ca39b83
diff --git a/src/metabase/notification/task/send.clj b/src/metabase/notification/task/send.clj
index 55774c820e6..5670afaf0a5 100644
--- a/src/metabase/notification/task/send.clj
+++ b/src/metabase/notification/task/send.clj
@@ -14,7 +14,7 @@
[toucan2.core :as t2])
(:import
(java.util TimeZone)
- (org.quartz CronTrigger DisallowConcurrentExecution TriggerKey)))
+ (org.quartz CronTrigger DisallowConcurrentExecution JobExecutionContext TriggerKey)))
(set! *warn-on-reflection* true)
@@ -158,8 +158,25 @@
(task/defjob ^{:doc "Triggers that send a notification for a subscription."}
SendNotification
[context]
- (let [{:strs [subscription-id]} (qc/from-job-data context)]
- (send-notification* subscription-id)))
+ (let [{:strs [subscription-id]} (qc/from-job-data context)
+ ^JobExecutionContext ctx context
+ scheduled-fire-time (.getScheduledFireTime ctx)
+ fire-time (.getFireTime ctx)
+ fire-instance-id (.getFireInstanceId ctx)
+ recovering? (.isRecovering ctx)
+ refire-count (.getRefireCount ctx)
+ trigger-key (.. ctx getTrigger getKey getName)
+ scheduler-id (.. ctx getScheduler getSchedulerInstanceId)]
+ (log/with-context {:quartz-fire-instance-id fire-instance-id
+ :quartz-scheduled-fire-time (str scheduled-fire-time)
+ :quartz-fire-time (str fire-time)
+ :quartz-recovering recovering?
+ :quartz-refire-count refire-count
+ :quartz-trigger-key trigger-key
+ :quartz-scheduler-id scheduler-id}
+ (log/infof "SendNotification fired for subscription %d (trigger=%s, scheduled=%s, actual=%s, recovering=%s, refire=%d, scheduler=%s)"
+ subscription-id trigger-key scheduled-fire-time fire-time recovering? refire-count scheduler-id)
+ (send-notification* subscription-id))))
(defn init-send-notification-triggers!
"Initialize all notification subscription triggers.
diff --git a/src/metabase/pulse/task/send_pulses.clj b/src/metabase/pulse/task/send_pulses.clj
index ec77baabb5b..765c6852a7a 100644
--- a/src/metabase/pulse/task/send_pulses.clj
+++ b/src/metabase/pulse/task/send_pulses.clj
@@ -23,7 +23,7 @@
[toucan2.core :as t2])
(:import
(java.util TimeZone)
- (org.quartz CronTrigger DisallowConcurrentExecution TriggerKey)))
+ (org.quartz CronTrigger DisallowConcurrentExecution JobExecutionContext TriggerKey)))
(set! *warn-on-reflection* true)
@@ -152,8 +152,25 @@
(task/defjob ^{:doc "Triggers that send a pulse to a list of channels at a specific time"}
SendPulse
[context]
- (let [{:strs [pulse-id channel-ids]} (qc/from-job-data context)]
- (send-pulse!* pulse-id channel-ids)))
+ (let [{:strs [pulse-id channel-ids]} (qc/from-job-data context)
+ ^JobExecutionContext ctx context
+ scheduled-fire-time (.getScheduledFireTime ctx)
+ fire-time (.getFireTime ctx)
+ fire-instance-id (.getFireInstanceId ctx)
+ recovering? (.isRecovering ctx)
+ refire-count (.getRefireCount ctx)
+ trigger-key (.. ctx getTrigger getKey getName)
+ scheduler-id (.. ctx getScheduler getSchedulerInstanceId)]
+ (log/with-context {:quartz-fire-instance-id fire-instance-id
+ :quartz-scheduled-fire-time (str scheduled-fire-time)
+ :quartz-fire-time (str fire-time)
+ :quartz-recovering recovering?
+ :quartz-refire-count refire-count
+ :quartz-trigger-key trigger-key
+ :quartz-scheduler-id scheduler-id}
+ (log/infof "SendPulse fired for pulse %d (trigger=%s, scheduled=%s, actual=%s, recovering=%s, refire=%d, scheduler=%s)"
+ pulse-id trigger-key scheduled-fire-time fire-time recovering? refire-count scheduler-id)
+ (send-pulse!* pulse-id channel-ids))))
(declare update-send-pulse-trigger-if-needed!)