From bea8da556036b24807f90f0eba1b615f34db2cfd Mon Sep 17 00:00:00 2001 From: David McDonald Date: Thu, 6 Jan 2022 11:24:39 +0000 Subject: [PATCH] Improve logging for adjusting provider priority on API failure We can deduce that our traffic is being reduced for one of our providers but we aren't logging that we are doing it so it is much harder to tell. This commit - makes it explicit what we are doing with a log line - also gives context on what the error was with the provider API so we can tell if it is say a 4xx or a 5xx --- app/celery/provider_tasks.py | 2 +- app/delivery/send_to_providers.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index 1b1bf6894..40de9d4c5 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -24,7 +24,7 @@ def deliver_sms(self, notification_id): except Exception as e: if isinstance(e, SmsClientResponseException): current_app.logger.warning( - "SMS notification delivery for id: {} failed".format(notification_id) + "SMS notification delivery for id: {} failed due to {}".format(notification_id, e) ) else: current_app.logger.exception( diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 37994691d..8c9f8553e 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -82,7 +82,12 @@ def send_sms_to_provider(notification): except Exception as e: notification.billable_units = template.fragment_count dao_update_notification(notification) - dao_reduce_sms_provider_priority(provider.get_name(), time_threshold=timedelta(minutes=1)) + + provider_name = provider.get_name() + current_app.logger.info( + "Reducing priority for {provider_name} due to exception raised when calling provider API" + ) + dao_reduce_sms_provider_priority(provider_name, time_threshold=timedelta(minutes=1)) raise e else: notification.billable_units = template.fragment_count