Skip to content

Commit 1498406

Browse files
authored
chore(issue assignment): Add logging forGroupOwner auto assignment (#45142)
There's currently a bug in our issue assignment logic such that suspect commits are sometimes passed over in favor of issue ownership rules or codeowners when auto-assigning an issue. For folks with Commit Context enabled, the calculating of suspect commits involves an API call to an outside service (GitHub or GitLab), meaning it's possible that this problem is caused by a race condition: when assignment happens, the data for suspect commit calculation may or may not have come back from the API yet. To test this hypothesis, it would be helpful to know when each stage of the process happened for an event with the wrong assignee. We already log the completion of suspect commit processing, but we don't log the completion of either ownership rule/code owners processing or the completion of auto-assignment. This PR adds that logging. Once it's merged, we'll need to look at logs for `process_commit_context.success` , `handle_owner_assignment.success`, and `handle_auto_assignment.success` .
1 parent 7c9f4b5 commit 1498406

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/sentry/models/projectownership.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from typing import TYPE_CHECKING, Any, Mapping, Optional, Sequence, Tuple, Union
23

34
from django.db import models
@@ -18,6 +19,8 @@
1819
from sentry.models import ProjectCodeOwners, Team
1920
from sentry.services.hybrid_cloud.user import RpcUser
2021

22+
logger = logging.getLogger(__name__)
23+
2124
READ_CACHE_DURATION = 3600
2225

2326

@@ -303,6 +306,19 @@ def handle_auto_assignment(cls, project_id, event):
303306
project_id=project_id,
304307
group_id=event.group.id,
305308
)
309+
logger.info(
310+
"handle_auto_assignment.success",
311+
extra={
312+
"event": event.event_id,
313+
"group": event.group_id,
314+
"project": event.project_id,
315+
"organization": event.project.organization_id,
316+
# owner_id returns a string including the owner type (user or team) and id
317+
"assignee": issue_owner.owner_id(),
318+
"reason": "created" if assignment["new_assignment"] else "updated",
319+
**details,
320+
},
321+
)
306322

307323
@classmethod
308324
def _matching_ownership_rules(

src/sentry/tasks/post_process.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ def handle_owner_assignment(job):
248248
if issue_owners:
249249
try:
250250
handle_group_owners(project, group, issue_owners)
251+
logger.info(
252+
"handle_owner_assignment.success",
253+
extra={
254+
**basic_logging_details,
255+
"reason": "stored_issue_owners",
256+
},
257+
)
251258
except Exception:
252259
logger.exception("Failed to store group owners")
253260
except Exception:

0 commit comments

Comments
 (0)