From dccea535d4ab7d882d28d7c9b1d85c0a52089815 Mon Sep 17 00:00:00 2001 From: Jimmy Royer Date: Thu, 23 May 2024 17:14:38 -0400 Subject: [PATCH] Rework callback logging (#2078) * Decoupled scan malware code + lowering retry period for high priority emails * Extract common email retry handling logic into its own function * Cleaned up import * Forgot to provide default value to optional fn arg * Fixed test import * Isolated retry task param builder in a class * Cleaned up import * Fixed moved refs * Trying a different strategy to fix circular import * Fixing another bad import ref * Introducing celery utils module instead of using celery root one * Cover edge cases + modified tests * Formatting * Sort imports * Make notification_process_type param optional * Fixed edge case when template not associated with notification obj * Fixing params order * Fixing regression tests * More tests * Added null protection against a potential NPE * Formatting * Fix imports * Moved logging for callback prior to actual call * Format service_callback_tasks.py --- app/celery/service_callback_tasks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/celery/service_callback_tasks.py b/app/celery/service_callback_tasks.py index af3d51e3b2..9296958f85 100644 --- a/app/celery/service_callback_tasks.py +++ b/app/celery/service_callback_tasks.py @@ -59,6 +59,7 @@ def send_complaint_to_service(self, complaint_data): def _send_data_to_service_callback_api(self, data, service_callback_url, token, function_name): notification_id = data["notification_id"] if "notification_id" in data else data["id"] try: + current_app.logger.info("{} sending {} to {}".format(function_name, notification_id, service_callback_url)) response = request( method="POST", url=service_callback_url, @@ -69,9 +70,11 @@ def _send_data_to_service_callback_api(self, data, service_callback_url, token, }, timeout=5, ) + current_app.logger.info( f"{function_name} sending {notification_id} to {service_callback_url}, response {response.status_code}" ) + response.raise_for_status() except RequestException as e: current_app.logger.warning(