Skip to content

Commit e901187

Browse files
iamrajjoshivishnupsatish
authored andcommitted
🔧 chore: update github slo collection and clean logs (#93279)
1 parent 11cb21a commit e901187

File tree

4 files changed

+23
-59
lines changed

4 files changed

+23
-59
lines changed

src/sentry/integrations/github/webhook.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ def get_file_language(filename: str) -> str | None:
6464
if extension != filename:
6565
language = EXTENSION_LANGUAGE_MAP.get(extension)
6666

67-
if language is None:
68-
logger.info("github.unaccounted_file_lang", extra={"extension": extension})
69-
7067
return language
7168

7269

src/sentry/integrations/source_code_management/commit_context.py

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -223,42 +223,34 @@ def queue_pr_comment_task_if_needed(
223223
except NotImplementedError:
224224
return
225225

226+
if not OrganizationOption.objects.get_value(
227+
organization=project.organization,
228+
key=pr_comment_workflow.organization_option_key,
229+
default=True,
230+
):
231+
return
232+
233+
repo_query = Repository.objects.filter(id=commit.repository_id).order_by("-date_added")
234+
group = Group.objects.get_from_cache(id=group_id)
235+
if not (
236+
group.level is not logging.INFO and repo_query.exists()
237+
): # Don't comment on info level issues
238+
return
239+
226240
with CommitContextIntegrationInteractionEvent(
227241
interaction_type=SCMIntegrationInteractionType.QUEUE_COMMENT_TASK,
228242
provider_key=self.integration_name,
229243
organization=project.organization,
230244
project=project,
231245
commit=commit,
232246
).capture() as lifecycle:
233-
if not OrganizationOption.objects.get_value(
234-
organization=project.organization,
235-
key=pr_comment_workflow.organization_option_key,
236-
default=True,
237-
):
238-
# TODO: remove logger in favor of the log recorded in lifecycle.record_halt
239-
logger.info(
240-
_pr_comment_log(integration_name=self.integration_name, suffix="disabled"),
241-
extra={"organization_id": project.organization_id},
242-
)
243-
lifecycle.record_halt(CommitContextHaltReason.PR_BOT_DISABLED)
244-
return
245-
246-
repo_query = Repository.objects.filter(id=commit.repository_id).order_by("-date_added")
247-
group = Group.objects.get_from_cache(id=group_id)
248-
if not (
249-
group.level is not logging.INFO and repo_query.exists()
250-
): # Don't comment on info level issues
251-
logger.info(
252-
_pr_comment_log(
253-
integration_name=self.integration_name, suffix="incorrect_repo_config"
254-
),
255-
extra={"organization_id": project.organization_id},
256-
)
257-
lifecycle.record_halt(CommitContextHaltReason.INCORRECT_REPO_CONFIG)
258-
return
259-
260247
repo: Repository = repo_query.get()
261-
lifecycle.add_extra("repository_id", repo.id)
248+
lifecycle.add_extras(
249+
{
250+
"repository_id": repo.id,
251+
"group_id": group_id,
252+
}
253+
)
262254

263255
logger.info(
264256
_pr_comment_log(
@@ -282,37 +274,18 @@ def queue_pr_comment_task_if_needed(
282274
return
283275

284276
if merge_commit_sha is None:
285-
logger.info(
286-
_pr_comment_log(
287-
integration_name=self.integration_name,
288-
suffix="queue_comment_workflow.commit_not_in_default_branch",
289-
),
290-
extra={
291-
"organization_id": commit.organization_id,
292-
"repository_id": repo.id,
293-
"commit_sha": commit.key,
294-
},
295-
)
277+
lifecycle.add_extra("commit_sha", commit.key)
296278
lifecycle.record_halt(CommitContextHaltReason.COMMIT_NOT_IN_DEFAULT_BRANCH)
297279
return
298280

281+
lifecycle.add_extra("merge_commit_sha", merge_commit_sha)
282+
299283
pr_query = PullRequest.objects.filter(
300284
organization_id=commit.organization_id,
301285
repository_id=commit.repository_id,
302286
merge_commit_sha=merge_commit_sha,
303287
)
304288
if not pr_query.exists():
305-
logger.info(
306-
_pr_comment_log(
307-
integration_name=self.integration_name,
308-
suffix="queue_comment_workflow.missing_pr",
309-
),
310-
extra={
311-
"organization_id": commit.organization_id,
312-
"repository_id": repo.id,
313-
"commit_sha": commit.key,
314-
},
315-
)
316289
lifecycle.record_halt(CommitContextHaltReason.MISSING_PR)
317290
return
318291

src/sentry/integrations/source_code_management/metrics.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ def get_extras(self) -> Mapping[str, Any]:
105105
class CommitContextHaltReason(StrEnum):
106106
"""Common reasons why a commit context integration may halt without success/failure."""
107107

108-
PR_BOT_DISABLED = "pr_bot_disabled"
109-
INCORRECT_REPO_CONFIG = "incorrect_repo_config"
110108
COMMIT_NOT_IN_DEFAULT_BRANCH = "commit_not_in_default_branch"
111109
MISSING_PR = "missing_pr"
112110
ALREADY_QUEUED = "already_queued"

src/sentry/integrations/source_code_management/tasks.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ def pr_comment_workflow(pr_id: int, project_id: int):
143143
top_5_issue_ids = [issue["group_id"] for issue in top_5_issues]
144144

145145
comment_body = pr_comment_workflow.get_comment_body(issue_ids=top_5_issue_ids)
146-
logger.info(
147-
_pr_comment_log(integration_name=integration_name, suffix="comment_body"),
148-
extra={"body": comment_body},
149-
)
150146

151147
top_24_issue_ids = issue_ids[:24] # 24 is the P99 for issues-per-PR
152148

0 commit comments

Comments
 (0)