Skip to content

Commit 9b06517

Browse files
committed
🔧 chore: add more logs to github sync assignee inbound
1 parent 93b6eea commit 9b06517

File tree

1 file changed

+22
-0
lines changed
  • src/sentry/integrations/utils

1 file changed

+22
-0
lines changed

src/sentry/integrations/utils/sync.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,36 @@ def _handle_assign(
9292
users_by_id = {user.id: user for user in users}
9393
projects_by_user = Project.objects.get_by_users(users)
9494

95+
logger = logging.getLogger(f"sentry.integrations.{integration.provider}")
96+
9597
for group in affected_groups:
9698
if not should_sync_assignee_inbound(group.organization, integration.provider):
9799
continue
98100

99101
user_id = _get_user_id(projects_by_user, group)
100102
user = users_by_id.get(user_id) if user_id is not None else None
101103
if user:
104+
logger.info(
105+
"sync_group_assignee_inbound._handle_assign.assigning.group",
106+
extra={
107+
"group_id": group.id,
108+
"user_id": user.id,
109+
},
110+
)
102111
GroupAssignee.objects.assign(
103112
group,
104113
user,
105114
assignment_source=AssignmentSource.from_integration(integration),
106115
)
107116
groups_assigned.append(group)
117+
else:
118+
logger.info(
119+
"sync_group_assignee_inbound._handle_assign.user_not_found",
120+
extra={
121+
"group_id": group.id,
122+
"user_id": user_id,
123+
},
124+
)
108125

109126
return groups_assigned
110127

@@ -147,6 +164,9 @@ def sync_group_assignee_inbound_by_external_actor(
147164
user_ids = [
148165
external_actor for external_actor in external_actors if external_actor is not None
149166
]
167+
log_context["user_ids"] = user_ids
168+
logger.info("sync_group_assignee_inbound_by_external_actor.user_ids", extra=log_context)
169+
150170
users = user_service.get_many_by_id(ids=user_ids)
151171

152172
groups_assigned = _handle_assign(affected_groups, integration, users)
@@ -196,6 +216,8 @@ def sync_group_assignee_inbound(
196216
groups_assigned = _handle_assign(affected_groups, integration, users)
197217

198218
if len(groups_assigned) != len(affected_groups):
219+
log_context["groups_assigned_count"] = len(groups_assigned)
220+
log_context["affected_groups_count"] = len(affected_groups)
199221
lifecycle.record_halt(
200222
ProjectManagementHaltReason.SYNC_INBOUND_ASSIGNEE_NOT_FOUND, extra=log_context
201223
)

0 commit comments

Comments
 (0)