Skip to content

Commit

Permalink
chore: some more logging (#17721)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Oct 2, 2023
1 parent fae1c4d commit 00b5a86
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions ee/tasks/subscriptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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")
Expand All @@ -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)


Expand Down

0 comments on commit 00b5a86

Please sign in to comment.