mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 00:41:35 -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:
@@ -50,11 +50,12 @@ class FiretextClient(SmsClient):
|
||||
FireText sms client.
|
||||
'''
|
||||
|
||||
def init_app(self, config, *args, **kwargs):
|
||||
def init_app(self, config, statsd_client, *args, **kwargs):
|
||||
super(SmsClient, self).__init__(*args, **kwargs)
|
||||
self.api_key = config.config.get('FIRETEXT_API_KEY')
|
||||
self.from_number = config.config.get('FIRETEXT_NUMBER')
|
||||
self.name = 'firetext'
|
||||
self.statsd_client = statsd_client
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
@@ -90,8 +91,10 @@ class FiretextClient(SmsClient):
|
||||
api_error.message
|
||||
)
|
||||
)
|
||||
self.statsd_client.incr("notifications.clients.firetext.error")
|
||||
raise api_error
|
||||
finally:
|
||||
elapsed_time = monotonic() - start_time
|
||||
current_app.logger.info("Firetext request finished in {}".format(elapsed_time))
|
||||
self.statsd_client.timing("notifications.clients.firetext.request-time", elapsed_time)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user