Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Detailed sendgrid email error logging #503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/async/notifications/implementations/sendgrid_emailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package implementations
import (
"context"
"io/ioutil"
"net/http"
"os"
"strings"

Expand Down Expand Up @@ -65,12 +66,16 @@ func (s SendgridEmailer) SendEmail(ctx context.Context, email admin.EmailMessage
s.systemMetrics.SendTotal.Inc()
response, err := s.client.Send(m)
if err != nil {
logger.Errorf(ctx, "Sendgrid error sending %s", err)
logger.Errorf(ctx, "Sendgrid error sending email [%+v] %w", email, err)
s.systemMetrics.SendError.Inc()
return err
}
s.systemMetrics.SendSuccess.Inc()
logger.Debugf(ctx, "Sendgrid sent email %s", response.Body)
if response.StatusCode != http.StatusOK {
logger.Errorf(ctx, "Sendgrid error sending email [%+v]: non-200 response received %d [%+v]",
email, response.StatusCode, response.Body)
}
logger.Debugf(ctx, "Sendgrid sent email [%+v] %s", email, response.Body)

return nil
}
Expand Down