From c0c62e02b72b8a7b10e199d2d4f82e722ae1515a Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 13 Oct 2016 14:17:17 +0100 Subject: [PATCH] move statsd call out of generic tryexcept we shouldn't try and use statsd to log an error if they fail, for example [we also shouldn't retry sending the message but that's a problem for another time] --- app/clients/email/aws_ses.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/clients/email/aws_ses.py b/app/clients/email/aws_ses.py index 63536ae43..4607d5fda 100644 --- a/app/clients/email/aws_ses.py +++ b/app/clients/email/aws_ses.py @@ -90,13 +90,15 @@ class AwsSesClient(EmailClient): }, 'Body': body }, - ReplyToAddresses=reply_to_addresses) - elapsed_time = monotonic() - start_time - current_app.logger.info("AWS SES request finished in {}".format(elapsed_time)) - self.statsd_client.timing("clients.ses.request-time", elapsed_time) - self.statsd_client.incr("clients.ses.success") - return response['MessageId'] + ReplyToAddresses=reply_to_addresses + ) except Exception as e: # TODO logging exceptions self.statsd_client.incr("clients.ses.error") raise AwsSesClientException(str(e)) + + elapsed_time = monotonic() - start_time + current_app.logger.info("AWS SES request finished in {}".format(elapsed_time)) + self.statsd_client.timing("clients.ses.request-time", elapsed_time) + self.statsd_client.incr("clients.ses.success") + return response['MessageId']