diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index afd1a4913..e979e91bc 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -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) diff --git a/app/clients/email/aws_ses.py b/app/clients/email/aws_ses.py index 6fe62e82a..63536ae43 100644 --- a/app/clients/email/aws_ses.py +++ b/app/clients/email/aws_ses.py @@ -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)) diff --git a/app/clients/sms/firetext.py b/app/clients/sms/firetext.py index 938a86689..e9760a4e6 100644 --- a/app/clients/sms/firetext.py +++ b/app/clients/sms/firetext.py @@ -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 diff --git a/app/clients/sms/mmg.py b/app/clients/sms/mmg.py index bec425966..9636be86b 100644 --- a/app/clients/sms/mmg.py +++ b/app/clients/sms/mmg.py @@ -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 diff --git a/app/notifications/process_client_response.py b/app/notifications/process_client_response.py index 595fbcd4d..737ad21c0 100644 --- a/app/notifications/process_client_response.py +++ b/app/notifications/process_client_response.py @@ -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 diff --git a/app/notifications/rest.py b/app/notifications/rest.py index 89d481a8b..5461c198e 100644 --- a/app/notifications/rest.py +++ b/app/notifications/rest.py @@ -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, diff --git a/tests/app/notifications/rest/test_callbacks.py b/tests/app/notifications/rest/test_callbacks.py index f045817a2..738e8ae95 100644 --- a/tests/app/notifications/rest/test_callbacks.py +++ b/tests/app/notifications/rest/test_callbacks.py @@ -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():