-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(autofix): Update seer explorer autofix last triggered on completion #111663
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
Changes from all commits
7863cbb
07df567
4f0e02a
564a21c
b156fec
20c11de
9d10fc3
383d741
0d3ffce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| import logging | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from django.utils import timezone | ||
|
|
||
| from sentry import features | ||
| from sentry.models.group import Group | ||
| from sentry.models.organization import Organization | ||
|
|
@@ -76,13 +78,20 @@ | |
| ) | ||
| return | ||
|
|
||
| group_id = state.metadata.get("group_id") if state.metadata else None | ||
| if group_id is None: | ||
| return | ||
|
|
||
| group = Group.objects.get(id=group_id, project__organization_id=organization.id) | ||
|
Check failure on line 85 in src/sentry/seer/autofix/on_completion_hook.py
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Suggested FixWrap the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
cursor[bot] marked this conversation as resolved.
|
||
| group.update(seer_explorer_autofix_last_triggered=timezone.now()) | ||
|
sentry[bot] marked this conversation as resolved.
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| # Send webhook for the completed step | ||
| cls._send_step_webhook(organization, run_id, state) | ||
| cls._send_step_webhook(organization, run_id, state, group) | ||
|
|
||
| cls._maybe_trigger_supergroups_embedding(organization, run_id, state) | ||
| cls._maybe_trigger_supergroups_embedding(organization, run_id, state, group) | ||
|
|
||
| # Continue the automated pipeline if stopping_point hasn't been reached | ||
| cls._maybe_continue_pipeline(organization, run_id, state) | ||
| cls._maybe_continue_pipeline(organization, run_id, state, group) | ||
|
|
||
| @classmethod | ||
| def find_latest_artifact_for_step(cls, state: SeerRunState, key: str) -> Artifact | None: | ||
|
|
@@ -95,19 +104,24 @@ | |
| return None | ||
|
|
||
| @classmethod | ||
| def _send_step_webhook(cls, organization, run_id, state: SeerRunState): | ||
| def _send_step_webhook( | ||
| cls, | ||
| organization: Organization, | ||
| run_id: int, | ||
| state: SeerRunState, | ||
| group: Group, | ||
| ): | ||
| """ | ||
| Send webhook for the completed step. | ||
|
|
||
| Determines which step just completed and sends the appropriate webhook event. | ||
| """ | ||
| current_step = cls._get_current_step(state) | ||
|
|
||
| webhook_payload = {"run_id": run_id} | ||
|
|
||
| group_id = state.metadata.get("group_id") if state.metadata else None | ||
| if group_id is not None: | ||
| webhook_payload["group_id"] = group_id | ||
| webhook_payload = { | ||
| "run_id": run_id, | ||
| "group_id": group.id, | ||
| } | ||
|
|
||
| # Iterate through blocks in reverse order (most recent first) | ||
| # to find which step just completed | ||
|
|
@@ -213,25 +227,13 @@ | |
| organization: Organization, | ||
| run_id: int, | ||
| state: SeerRunState, | ||
| group: Group, | ||
|
Check failure on line 230 in src/sentry/seer/autofix/on_completion_hook.py
|
||
| ) -> None: | ||
| """Trigger supergroups embedding if feature flag is enabled.""" | ||
| current_step = cls._get_current_step(state) | ||
| if current_step != AutofixStep.ROOT_CAUSE: | ||
| return | ||
|
|
||
| group_id = state.metadata.get("group_id") if state.metadata else None | ||
| if group_id is None: | ||
| return | ||
|
|
||
| try: | ||
| group = Group.objects.get(id=group_id) | ||
| except Group.DoesNotExist: | ||
| logger.warning( | ||
| "autofix.supergroup_embedding.group_not_found", | ||
| extra={"group_id": group_id}, | ||
| ) | ||
| return | ||
|
|
||
| if not features.has("projects:supergroup-embeddings-explorer", group.project): | ||
| return | ||
|
|
||
|
|
@@ -242,7 +244,7 @@ | |
| try: | ||
| trigger_supergroups_embedding( | ||
| organization_id=organization.id, | ||
| group_id=group_id, | ||
| group_id=group.id, | ||
| project_id=group.project_id, | ||
| artifact_data=root_cause_artifact.data, | ||
| ) | ||
|
|
@@ -252,7 +254,7 @@ | |
| extra={ | ||
| "run_id": run_id, | ||
| "organization_id": organization.id, | ||
| "group_id": group_id, | ||
| "group_id": group.id, | ||
| }, | ||
| ) | ||
|
|
||
|
|
@@ -289,6 +291,7 @@ | |
| organization: Organization, | ||
| run_id: int, | ||
| state: SeerRunState, | ||
| group: Group, | ||
| ) -> None: | ||
| """ | ||
| Continue to the next step if stopping_point hasn't been reached. | ||
|
|
@@ -307,28 +310,6 @@ | |
| return | ||
|
|
||
| stopping_point = AutofixStoppingPoint(metadata["stopping_point"]) | ||
| group_id = metadata.get("group_id") | ||
|
|
||
| if not group_id: | ||
| logger.warning( | ||
| "autofix.on_completion_hook.no_group_id_in_metadata", | ||
| extra={"run_id": run_id, "organization_id": organization.id}, | ||
| ) | ||
| return | ||
|
|
||
| # Get the group | ||
| try: | ||
| group = Group.objects.get(id=group_id, project__organization=organization) | ||
| except Group.DoesNotExist: | ||
| logger.warning( | ||
| "autofix.on_completion_hook.group_not_found", | ||
| extra={ | ||
| "run_id": run_id, | ||
| "organization_id": organization.id, | ||
| "group_id": group_id, | ||
| }, | ||
| ) | ||
| return | ||
|
|
||
| if current_step is None: | ||
| logger.warning( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.