From 00b5a86139489dabcb0a0ad2b6acb961a9ed081c Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Mon, 2 Oct 2023 20:30:03 +0100 Subject: [PATCH] chore: some more logging (#17721) --- ee/tasks/subscriptions/__init__.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/ee/tasks/subscriptions/__init__.py b/ee/tasks/subscriptions/__init__.py index 8d1a583629bd8..416e0a3337533 100644 --- a/ee/tasks/subscriptions/__init__.py +++ b/ee/tasks/subscriptions/__init__.py @@ -4,7 +4,6 @@ import structlog from prometheus_client import Counter from sentry_sdk import capture_exception -from statshog.defaults.django import statsd from ee.tasks.subscriptions.email_subscriptions import send_email_subscription_report from ee.tasks.subscriptions.slack_subscriptions import send_slack_subscription_report @@ -64,7 +63,13 @@ def _deliver_subscription_report( ) except Exception as e: SUBSCRIPTION_FAILURE.labels(destination="email").inc() - logger.error(e) + logger.error( + "sending subscription failed", + subscription_id=subscription.id, + next_delivery_date=subscription.next_delivery_date, + destination=subscription.target_type, + exc_info=True, + ) capture_exception(e) SUBSCRIPTION_SUCCESS.labels(destination="email").inc() @@ -80,7 +85,13 @@ def _deliver_subscription_report( SUBSCRIPTION_SUCCESS.labels(destination="slack").inc() except Exception as e: SUBSCRIPTION_FAILURE.labels(destination="slack").inc() - logger.error(e) + logger.error( + "sending subscription failed", + subscription_id=subscription.id, + next_delivery_date=subscription.next_delivery_date, + destination=subscription.target_type, + exc_info=True, + ) capture_exception(e) else: raise NotImplementedError(f"{subscription.target_type} is not supported") @@ -106,6 +117,12 @@ def schedule_all_subscriptions() -> None: ) for subscription in subscriptions: + logger.info( + "Scheduling subscription", + subscription_id=subscription.id, + next_delivery_date=subscription.next_delivery_date, + destination=subscription.target_type, + ) deliver_subscription_report.delay(subscription.id)