Skip to content

🔧 chore: update github slo collection and clean logs #93279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/sentry/integrations/github/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ def get_file_language(filename: str) -> str | None:
if extension != filename:
language = EXTENSION_LANGUAGE_MAP.get(extension)

if language is None:
logger.info("github.unaccounted_file_lang", extra={"extension": extension})

return language


Expand Down
73 changes: 23 additions & 50 deletions src/sentry/integrations/source_code_management/commit_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,42 +223,34 @@ def queue_pr_comment_task_if_needed(
except NotImplementedError:
return

if not OrganizationOption.objects.get_value(
organization=project.organization,
key=pr_comment_workflow.organization_option_key,
default=True,
):
return

repo_query = Repository.objects.filter(id=commit.repository_id).order_by("-date_added")
group = Group.objects.get_from_cache(id=group_id)
if not (
group.level is not logging.INFO and repo_query.exists()
): # Don't comment on info level issues
return

with CommitContextIntegrationInteractionEvent(
interaction_type=SCMIntegrationInteractionType.QUEUE_COMMENT_TASK,
provider_key=self.integration_name,
organization=project.organization,
project=project,
commit=commit,
).capture() as lifecycle:
if not OrganizationOption.objects.get_value(
organization=project.organization,
key=pr_comment_workflow.organization_option_key,
default=True,
):
# TODO: remove logger in favor of the log recorded in lifecycle.record_halt
logger.info(
_pr_comment_log(integration_name=self.integration_name, suffix="disabled"),
extra={"organization_id": project.organization_id},
)
lifecycle.record_halt(CommitContextHaltReason.PR_BOT_DISABLED)
return

repo_query = Repository.objects.filter(id=commit.repository_id).order_by("-date_added")
group = Group.objects.get_from_cache(id=group_id)
if not (
group.level is not logging.INFO and repo_query.exists()
): # Don't comment on info level issues
logger.info(
_pr_comment_log(
integration_name=self.integration_name, suffix="incorrect_repo_config"
),
extra={"organization_id": project.organization_id},
)
lifecycle.record_halt(CommitContextHaltReason.INCORRECT_REPO_CONFIG)
return

repo: Repository = repo_query.get()
lifecycle.add_extra("repository_id", repo.id)
lifecycle.add_extras(
{
"repository_id": repo.id,
"group_id": group_id,
}
)

logger.info(
_pr_comment_log(
Expand All @@ -282,37 +274,18 @@ def queue_pr_comment_task_if_needed(
return

if merge_commit_sha is None:
logger.info(
_pr_comment_log(
integration_name=self.integration_name,
suffix="queue_comment_workflow.commit_not_in_default_branch",
),
extra={
"organization_id": commit.organization_id,
"repository_id": repo.id,
"commit_sha": commit.key,
},
)
lifecycle.add_extra("commit_sha", commit.key)
lifecycle.record_halt(CommitContextHaltReason.COMMIT_NOT_IN_DEFAULT_BRANCH)
return

lifecycle.add_extra("merge_commit_sha", merge_commit_sha)

pr_query = PullRequest.objects.filter(
organization_id=commit.organization_id,
repository_id=commit.repository_id,
merge_commit_sha=merge_commit_sha,
)
if not pr_query.exists():
logger.info(
_pr_comment_log(
integration_name=self.integration_name,
suffix="queue_comment_workflow.missing_pr",
),
extra={
"organization_id": commit.organization_id,
"repository_id": repo.id,
"commit_sha": commit.key,
},
)
lifecycle.record_halt(CommitContextHaltReason.MISSING_PR)
return

Expand Down
2 changes: 0 additions & 2 deletions src/sentry/integrations/source_code_management/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ def get_extras(self) -> Mapping[str, Any]:
class CommitContextHaltReason(StrEnum):
"""Common reasons why a commit context integration may halt without success/failure."""

PR_BOT_DISABLED = "pr_bot_disabled"
INCORRECT_REPO_CONFIG = "incorrect_repo_config"
COMMIT_NOT_IN_DEFAULT_BRANCH = "commit_not_in_default_branch"
MISSING_PR = "missing_pr"
ALREADY_QUEUED = "already_queued"
Expand Down
4 changes: 0 additions & 4 deletions src/sentry/integrations/source_code_management/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ def pr_comment_workflow(pr_id: int, project_id: int):
top_5_issue_ids = [issue["group_id"] for issue in top_5_issues]

comment_body = pr_comment_workflow.get_comment_body(issue_ids=top_5_issue_ids)
logger.info(
_pr_comment_log(integration_name=integration_name, suffix="comment_body"),
extra={"body": comment_body},
)

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

Expand Down
Loading