mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Added statsd integration into the API
- new client for statsd, follows conventions used elsewhere for configuration - client wraps underlying library so we can use a config property to send/not send statsd Added statsd metrics for: - count of API successful calls SMS/Email - count of successful task execution for SMS/Email - count of errors from Client libraries - timing of API calls to third party clients - timing of how long messages live on the SQS queue
This commit is contained in:
@@ -39,10 +39,11 @@ class AwsSesClient(EmailClient):
|
||||
Amazon SES email client.
|
||||
'''
|
||||
|
||||
def init_app(self, region, *args, **kwargs):
|
||||
def init_app(self, region, statsd_client, *args, **kwargs):
|
||||
self._client = boto3.client('ses', region_name=region)
|
||||
super(AwsSesClient, self).__init__(*args, **kwargs)
|
||||
self.name = 'ses'
|
||||
self.statsd_client = statsd_client
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
@@ -88,7 +89,9 @@ class AwsSesClient(EmailClient):
|
||||
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("notifications.clients.ses.request-time", elapsed_time)
|
||||
return response['MessageId']
|
||||
except Exception as e:
|
||||
# TODO logging exceptions
|
||||
self.statsd_client.incr("notifications.clients.ses.error")
|
||||
raise AwsSesClientException(str(e))
|
||||
|
||||
Reference in New Issue
Block a user