Browse Source

chore(github-comments): add loggers to tasks (#51167)

Cathy Teng 1 year ago
parent
commit
4847a1c5e3

+ 4 - 0
src/sentry/tasks/commit_context.py

@@ -47,6 +47,10 @@ def queue_comment_task_if_needed(commit: Commit, group_owner: GroupOwner):
         or group_owner.group_id not in pr.pullrequestcomment_set.get().group_ids
     ):
         # TODO: Debouncing Logic
+        logger.info(
+            "github.pr_comment.queue_comment_task",
+            extra={"pullrequest_id": pr.id, "project_id": group_owner.project_id},
+        )
         comment_workflow.delay(pullrequest_id=pr.id, project_id=group_owner.project_id)
 
 

+ 6 - 0
src/sentry/tasks/integrations/github/pr_comment.py

@@ -142,6 +142,11 @@ def create_or_update_comment(
         pr_comment.group_ids = issue_list
         pr_comment.save()
 
+    logger.info(
+        "github.pr_comment.create_or_update_comment",
+        extra={"created": pr_comment is None, "pr_key": pr_key, "repo": repo.name},
+    )
+
 
 @instrumented_task(name="sentry.tasks.integrations.github_pr_comments")
 def comment_workflow(pullrequest_id: int, project_id: int):
@@ -156,6 +161,7 @@ def comment_workflow(pullrequest_id: int, project_id: int):
 
     # TODO(cathy): add check for OrganizationOption for comment bot
     if not features.has("organizations:pr-comment-bot", organization):
+        logger.error("github.pr_comment.feature_flag_missing", extra={"organization_id": org_id})
         return
 
     pr_comment = None