Browse Source

Add additional logs for weekly report investigation (#71629)

## Description
We currently have logs for notifications, but there all happening after
a few retry events and it's difficult to tell what is triggering another
send. Existing metrics are just saying that we are invoking send
mulitple times, but not what triggered the calls.

I also found a spot where we have a UUID per template send, we can
likely utilize this uuid to mark the email as "sent".
Josh Callender 9 months ago
parent
commit
0225cbd195
1 changed files with 11 additions and 0 deletions
  1. 11 0
      src/sentry/tasks/summaries/weekly_reports.py

+ 11 - 0
src/sentry/tasks/summaries/weekly_reports.py

@@ -76,6 +76,9 @@ def schedule_organizations(
         organizations, step=10000, result_value_getter=lambda item: item.id
     ):
         # Create a celery task per organization
+        logger.info(
+            "weekly_reports.schedule_organizations", extra={"organization": organization.id}
+        )
         prepare_organization_report.delay(timestamp, duration, organization.id, dry_run=dry_run)
 
 
@@ -214,6 +217,7 @@ def prepare_organization_report(
 
     # Finally, deliver the reports
     with sentry_sdk.start_span(op="weekly_reports.deliver_reports"):
+        logger.info("weekly_reports.deliver_reports", extra={"organization": organization_id})
         deliver_reports(
             ctx, dry_run=dry_run, target_user=target_user, email_override=email_override
         )
@@ -687,5 +691,12 @@ def send_email(
             notification_uuid=template_ctx["notification_uuid"],
             user_project_count=template_ctx["user_project_count"],
         )
+
+        # TODO see if we can use the UUID to track if the email was sent or not
+        logger.info(
+            "weekly_report.send_email",
+            extra={"organization": ctx.organization.id, "uuid": template_ctx["notification_uuid"]},
+        )
+
         message.add_users((user_id,))
         message.send_async()