Skip to content

feat(seer): Add issue summary to post process #90710

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions src/sentry/tasks/autofix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime, timedelta

from sentry.autofix.utils import AutofixStatus, get_autofix_state
from sentry.models.group import Group
from sentry.tasks.base import instrumented_task
from sentry.taskworker.config import TaskworkerConfig
from sentry.taskworker.namespaces import issues_tasks
Expand Down Expand Up @@ -32,3 +33,19 @@ def check_autofix_status(run_id: int):
logger.error(
"Autofix run has been processing for more than 5 minutes", extra={"run_id": run_id}
)


@instrumented_task(
name="sentry.tasks.autofix.start_seer_automation",
max_retries=1,
taskworker_config=TaskworkerConfig(
namespace=issues_tasks,
retry=Retry(
times=1,
),
),
)
def start_seer_automation(group: Group):
from sentry.seer.issue_summary import get_issue_summary

get_issue_summary(group=group, source="post_process")
15 changes: 15 additions & 0 deletions src/sentry/tasks/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,20 @@ def check_if_flags_sent(job: PostProcessJob) -> None:
first_flag_received.send_robust(project=project, sender=Project)


def kick_off_seer_automation(job: PostProcessJob) -> None:
from sentry.tasks.autofix import start_seer_automation

event = job["event"]
group = event.group

if not features.has("organizations:gen-ai-features", group.organization) or not features.has(
"projects:trigger-issue-summary-on-alerts", group.project
):
return

start_seer_automation.delay(group)


GROUP_CATEGORY_POST_PROCESS_PIPELINE = {
GroupCategory.ERROR: [
_capture_group_stats,
Expand All @@ -1559,6 +1573,7 @@ def check_if_flags_sent(job: PostProcessJob) -> None:
process_commits,
handle_owner_assignment,
handle_auto_assignment,
kick_off_seer_automation,
process_rules,
process_workflow_engine,
process_service_hooks,
Expand Down
53 changes: 53 additions & 0 deletions tests/sentry/tasks/test_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,58 @@ def test_skip_process_similarity_global(self, mock_safe_execute):
self.assert_not_called_with(mock_safe_execute)


class KickOffSeerAutomationTestMixin(BasePostProgressGroupMixin):
@patch("sentry.tasks.autofix.start_seer_automation.delay")
@with_feature("organizations:gen-ai-features")
@with_feature("projects:trigger-issue-summary-on-alerts")
def test_kick_off_seer_automation_with_features(self, mock_start_seer_automation):
event = self.create_event(
data={"message": "testing"},
project_id=self.project.id,
)

self.call_post_process_group(
is_new=True,
is_regression=False,
is_new_group_environment=True,
event=event,
)

mock_start_seer_automation.assert_called_once_with(event.group)

@patch("sentry.tasks.autofix.start_seer_automation.delay")
def test_kick_off_seer_automation_without_org_feature(self, mock_start_seer_automation):
event = self.create_event(
data={"message": "testing"},
project_id=self.project.id,
)
with self.feature("projects:trigger-issue-summary-on-alerts"):
self.call_post_process_group(
is_new=True,
is_regression=False,
is_new_group_environment=True,
event=event,
)

mock_start_seer_automation.assert_not_called()

@patch("sentry.tasks.autofix.start_seer_automation.delay")
def test_kick_off_seer_automation_without_proj_feature(self, mock_start_seer_automation):
event = self.create_event(
data={"message": "testing"},
project_id=self.project.id,
)
with self.feature("organizations:gen-ai-features"):
self.call_post_process_group(
is_new=True,
is_regression=False,
is_new_group_environment=True,
event=event,
)

mock_start_seer_automation.assert_not_called()


class PostProcessGroupErrorTest(
TestCase,
AssignmentTestMixin,
Expand All @@ -2477,6 +2529,7 @@ class PostProcessGroupErrorTest(
DeriveCodeMappingsProcessGroupTestMixin,
InboxTestMixin,
ResourceChangeBoundsTestMixin,
KickOffSeerAutomationTestMixin,
RuleProcessorTestMixin,
ServiceHooksTestMixin,
SnoozeTestMixin,
Expand Down
Loading