diff --git a/courier/courier_dispatcher.go b/courier/courier_dispatcher.go index 41369e201eb2..1c2af13defba 100644 --- a/courier/courier_dispatcher.go +++ b/courier/courier_dispatcher.go @@ -14,6 +14,7 @@ func (c *courier) DispatchMessage(ctx context.Context, msg Message) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to increment the message's "send_count" field`) return err } @@ -35,12 +36,14 @@ func (c *courier) DispatchMessage(ctx context.Context, msg Message) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to set the message status to "sent".`) return err } c.deps.Logger(). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). WithField("message_type", msg.Type). WithField("message_template_type", msg.TemplateType). WithField("message_subject", msg.Subject). @@ -66,12 +69,14 @@ func (c *courier) DispatchQueue(ctx context.Context) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to set the retried message's status to "abandoned".`) return err } // Skip the message c.deps.Logger(). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Warnf(`Message was abandoned because it did not deliver after %d attempts`, msg.SendCount) } else if err := c.DispatchMessage(ctx, msg); err != nil { @@ -80,6 +85,7 @@ func (c *courier) DispatchQueue(ctx context.Context) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to record failure log entry.`) } @@ -91,6 +97,7 @@ func (c *courier) DispatchQueue(ctx context.Context) error { c.deps.Logger(). WithError(err). WithField("message_id", replace.ID). + WithField("message_nid", replace.NID). Error(`Unable to reset the failed message's status to "queued".`) } } @@ -100,6 +107,7 @@ func (c *courier) DispatchQueue(ctx context.Context) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to record success log entry.`) // continue with execution, as the message was successfully dispatched } diff --git a/courier/smtp.go b/courier/smtp.go index 6411b27a3df9..000742e70bea 100644 --- a/courier/smtp.go +++ b/courier/smtp.go @@ -186,6 +186,7 @@ func (c *courier) dispatchEmail(ctx context.Context, msg Message) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to get email template from message.`) } else { htmlBody, err := tmpl.EmailBody(ctx) @@ -193,6 +194,7 @@ func (c *courier) dispatchEmail(ctx context.Context, msg Message) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to get email body from template.`) } else { gm.AddAlternative("text/html", htmlBody) @@ -205,6 +207,8 @@ func (c *courier) dispatchEmail(ctx context.Context, msg Message) error { WithField("smtp_server", fmt.Sprintf("%s:%d", c.smtpClient.Host, c.smtpClient.Port)). WithField("smtp_ssl_enabled", c.smtpClient.SSL). WithField("message_from", from). + WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error("Unable to send email using SMTP connection.") var protoErr *textproto.Error @@ -215,6 +219,7 @@ func (c *courier) dispatchEmail(ctx context.Context, msg Message) error { c.deps.Logger(). WithError(err). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). Error(`Unable to reset the retried message's status to "abandoned".`) return err } @@ -225,6 +230,7 @@ func (c *courier) dispatchEmail(ctx context.Context, msg Message) error { c.deps.Logger(). WithField("message_id", msg.ID). + WithField("message_nid", msg.NID). WithField("message_type", msg.Type). WithField("message_template_type", msg.TemplateType). WithField("message_subject", msg.Subject).