mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-14 01:02:09 -05:00
Final pass through existing statsd endpoints to ensure they match new naming strategy.
Updates accordingly.
This commit is contained in:
@@ -102,7 +102,7 @@ def send_sms_to_provider(self, service_id, notification_id):
|
||||
"SMS {} sent to provider at {}".format(notification_id, notification.sent_at)
|
||||
)
|
||||
delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000
|
||||
statsd_client.timing("notifications.sms.total-time", delta_milliseconds)
|
||||
statsd_client.timing("sms.total-time", delta_milliseconds)
|
||||
|
||||
|
||||
def provider_to_use(notification_type, notification_id):
|
||||
@@ -182,4 +182,4 @@ def send_email_to_provider(self, service_id, notification_id):
|
||||
"Email {} sent to provider at {}".format(notification_id, notification.sent_at)
|
||||
)
|
||||
delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000
|
||||
statsd_client.timing("notifications.email.total-time", delta_milliseconds)
|
||||
statsd_client.timing("email.total-time", delta_milliseconds)
|
||||
|
||||
@@ -93,9 +93,10 @@ 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)
|
||||
self.statsd_client.timing("clients.ses.request-time", elapsed_time)
|
||||
self.statsd_client.incr("clients.ses.success")
|
||||
return response['MessageId']
|
||||
except Exception as e:
|
||||
# TODO logging exceptions
|
||||
self.statsd_client.incr("notifications.clients.ses.error")
|
||||
self.statsd_client.incr("clients.ses.error")
|
||||
raise AwsSesClientException(str(e))
|
||||
|
||||
@@ -106,10 +106,11 @@ class FiretextClient(SmsClient):
|
||||
api_error.message
|
||||
)
|
||||
)
|
||||
self.statsd_client.incr("notifications.clients.firetext.error")
|
||||
self.statsd_client.incr("clients.firetext.error")
|
||||
raise api_error
|
||||
finally:
|
||||
elapsed_time = monotonic() - start_time
|
||||
self.current_app.logger.info("Firetext request finished in {}".format(elapsed_time))
|
||||
self.statsd_client.timing("notifications.clients.firetext.request-time", elapsed_time)
|
||||
self.statsd_client.incr("clients.firetext.success")
|
||||
self.statsd_client.timing("clients.firetext.request-time", elapsed_time)
|
||||
return response
|
||||
|
||||
@@ -106,10 +106,11 @@ class MMGClient(SmsClient):
|
||||
api_error.message
|
||||
)
|
||||
)
|
||||
self.statsd_client.incr("notifications.clients.mmg.error")
|
||||
self.statsd_client.incr("clients.mmg.error")
|
||||
raise api_error
|
||||
finally:
|
||||
elapsed_time = monotonic() - start_time
|
||||
self.statsd_client.timing("notifications.clients.mmg.request-time", elapsed_time)
|
||||
self.statsd_client.timing("clients.mmg.request-time", elapsed_time)
|
||||
self.statsd_client.incr("clients.mmg.success")
|
||||
self.current_app.logger.info("MMG request finished in {}".format(elapsed_time))
|
||||
return response
|
||||
|
||||
@@ -39,8 +39,6 @@ def process_sms_client_response(status, reference, client_name):
|
||||
except KeyError:
|
||||
return success, 'unknown sms client: {}'.format(client_name)
|
||||
|
||||
statsd_client.incr('callback.{}.status.{}'.format(client_name.lower(), status))
|
||||
|
||||
# validate status
|
||||
try:
|
||||
response_dict = response_parser(status)
|
||||
@@ -71,6 +69,6 @@ def process_sms_client_response(status, reference, client_name):
|
||||
reference,
|
||||
notification_status_message))
|
||||
|
||||
statsd_client.incr('notifications.callback.{}.{}'.format(client_name.lower(), notification_statistics_status))
|
||||
statsd_client.incr('callback.{}.{}'.format(client_name.lower(), notification_statistics_status))
|
||||
success = "{} callback succeeded. reference {} updated".format(client_name, reference)
|
||||
return success, errors
|
||||
|
||||
@@ -102,7 +102,7 @@ def process_ses_response():
|
||||
)
|
||||
)
|
||||
|
||||
statsd_client.incr('notifications.callback.ses.{}'.format(notification_statistics_status))
|
||||
statsd_client.incr('callback.ses.{}'.format(notification_statistics_status))
|
||||
return jsonify(
|
||||
result="success", message="SES callback succeeded"
|
||||
), 200
|
||||
@@ -305,7 +305,6 @@ def send_notification(notification_type):
|
||||
queue='email'
|
||||
)
|
||||
|
||||
statsd_client.incr('notifications.api.{}'.format(notification_type))
|
||||
return jsonify(
|
||||
data=get_notification_return_data(
|
||||
notification_id,
|
||||
|
||||
@@ -679,7 +679,7 @@ def test_process_mmg_response_records_statsd(notify_api, sample_notification, mo
|
||||
client.post(path='notifications/sms/mmg',
|
||||
data=data,
|
||||
headers=[('Content-Type', 'application/json')])
|
||||
app.statsd_client.incr.assert_any_call("notifications.callback.mmg.delivered")
|
||||
app.statsd_client.incr.assert_any_call("callback.mmg.delivered")
|
||||
|
||||
|
||||
def test_firetext_callback_should_record_statsd(notify_api, notify_db, notify_db_session, mocker):
|
||||
@@ -695,7 +695,7 @@ def test_firetext_callback_should_record_statsd(notify_api, notify_db, notify_db
|
||||
),
|
||||
headers=[('Content-Type', 'application/x-www-form-urlencoded')])
|
||||
|
||||
app.statsd_client.incr.assert_any_call("notifications.callback.firetext.delivered")
|
||||
app.statsd_client.incr.assert_any_call("callback.firetext.delivered")
|
||||
|
||||
|
||||
def ses_validation_code_callback():
|
||||
|
||||
Reference in New Issue
Block a user