Skip to content
Snippets Groups Projects
Unverified Commit 24c55f8a authored by github-automation-metabase's avatar github-automation-metabase Committed by GitHub
Browse files

Add more logs for sending notification (#50836) (#50849)


Co-authored-by: default avatarNgoc Khuat <qn.khuat@gmail.com>
parent e48212bc
No related branches found
No related tags found
No related merge requests found
......@@ -99,7 +99,7 @@
(log/debugf "[Notification %d] Sent to channel %s with %d retries"
notification-id (handler->channel-name handler) (count @retry-errors))))
(catch Throwable e
(log/errorf e "[Notification %d] Error sending notification!" (:notification_id handler)))))
(log/errorf e "[Notification %d] Error sending notification!" notification-id))))
(defn- noti-handlers
[notification-info]
......@@ -136,33 +136,33 @@
"Send the notification to all handlers synchronously. Do not use this directly, use *send-notification!* instead."
[notification-info :- notification.payload/Notification]
(try
(let [handlers (noti-handlers notification-info)
notification-payload (notification.payload/notification-payload notification-info)]
(if (notification.payload/should-send-notification? notification-payload)
(do
(log/debugf "[Notification %d] Found %d handlers" (:id notification-info) (count handlers))
(task-history/with-task-history
{:task "notification-send"
:task_details {:notification_id (:id notification-info)
:notification_handlers (map #(select-keys % [:id :channel_type :channel_id :template_id]) handlers)}}
(doseq [handler handlers]
(let [channel-type (:channel_type handler)
messages (channel/render-notification
channel-type
notification-payload
(:template handler)
(:recipients handler))]
(log/debugf "[Notification %d] Got %d messages for channel %s with template %d"
(:id notification-info) (count messages)
(handler->channel-name handler)
(-> handler :template :id))
(doseq [message messages]
(log/infof "[Notification %d] Sending message to channel %s"
(:id notification-info) (:channel_type handler))
(channel-send-retrying! (:id notification-info) (:payload_type notification-info) handler message))))
(do-after-notification-sent notification-info)
(log/infof "[Notification %d] Sent successfully" (:id notification-info))))
(log/infof "[Notification %d] Skipping" (:id notification-info))))
(log/infof "[Notification %d] Sending" (:id notification-info))
(let [handlers (noti-handlers notification-info)]
(task-history/with-task-history {:task "notification-send"
:task_details {:notification_id (:id notification-info)
:notification_handlers (map #(select-keys % [:id :channel_type :channel_id :template_id]) handlers)}}
(let [notification-payload (notification.payload/notification-payload notification-info)]
(if (notification.payload/should-send-notification? notification-payload)
(do
(log/debugf "[Notification %d] Found %d handlers" (:id notification-info) (count handlers))
(doseq [handler handlers]
(let [channel-type (:channel_type handler)
messages (channel/render-notification
channel-type
notification-payload
(:template handler)
(:recipients handler))]
(log/debugf "[Notification %d] Got %d messages for channel %s with template %d"
(:id notification-info) (count messages)
(handler->channel-name handler)
(-> handler :template :id))
(doseq [message messages]
(log/infof "[Notification %d] Sending message to channel %s"
(:id notification-info) (:channel_type handler))
(channel-send-retrying! (:id notification-info) (:payload_type notification-info) handler message))))
(do-after-notification-sent notification-info)
(log/infof "[Notification %d] Sent successfully" (:id notification-info)))
(log/infof "[Notification %d] Skipping" (:id notification-info))))))
(catch Exception e
(log/errorf e "[Notification %d] Failed to send" (:id notification-info))
(throw e)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment