-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(triage signals): New kick_off_seer_automation flow [feature flagged] #103676
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 8 commits
8975ae4
23ac235
82589d8
f36bfd5
c224823
38d3365
d7f3127
51ee208
e0dfbbc
d6d3355
0aa797c
96e5c1b
c8a2c45
d506aa3
66c92e5
bb66cfd
147b24e
1efbdf5
df4d3c9
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 |
|---|---|---|
|
|
@@ -1595,33 +1595,90 @@ def check_if_flags_sent(job: PostProcessJob) -> None: | |
|
|
||
|
|
||
| def kick_off_seer_automation(job: PostProcessJob) -> None: | ||
| from sentry.seer.autofix.issue_summary import get_issue_summary_lock_key | ||
| from sentry.seer.autofix.issue_summary import ( | ||
| get_issue_summary_cache_key, | ||
| get_issue_summary_lock_key, | ||
| ) | ||
| from sentry.seer.autofix.utils import ( | ||
| is_issue_eligible_for_seer_automation, | ||
| is_seer_scanner_rate_limited, | ||
| ) | ||
| from sentry.tasks.autofix import start_seer_automation | ||
| from sentry.tasks.autofix import ( | ||
| generate_issue_summary_only, | ||
| run_automation_for_group, | ||
| start_seer_automation, | ||
| ) | ||
|
|
||
| event = job["event"] | ||
| group = event.group | ||
|
|
||
| # Only run on issues with no existing scan - TODO: Update condition for triage signals V0 | ||
| if group.seer_fixability_score is not None: | ||
| return | ||
| # Default behaviour | ||
| if not features.has("projects:triage-signals-v0", group.project): | ||
| # Only run on issues with no existing scan | ||
| if group.seer_fixability_score is not None: | ||
| return | ||
|
|
||
| if is_issue_eligible_for_seer_automation(group) is False: | ||
| return | ||
| if is_issue_eligible_for_seer_automation(group) is False: | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return | ||
|
|
||
| # Don't run if there's already a task in progress for this issue | ||
| lock_key, lock_name = get_issue_summary_lock_key(group.id) | ||
| lock = locks.get(lock_key, duration=1, name=lock_name) | ||
| if lock.locked(): | ||
| return | ||
| # Don't run if there's already a task in progress for this issue | ||
| lock_key, lock_name = get_issue_summary_lock_key(group.id) | ||
| lock = locks.get(lock_key, duration=1, name=lock_name) | ||
| if lock.locked(): | ||
| return | ||
|
|
||
| if is_seer_scanner_rate_limited(group.project, group.organization): | ||
| return | ||
| if is_seer_scanner_rate_limited(group.project, group.organization): | ||
| return | ||
|
|
||
| start_seer_automation.delay(group.id) | ||
| else: | ||
| # Triage signals V0 behaviour | ||
|
|
||
| # If event count < 10, only generate summary (no automation) | ||
| if group.times_seen < 10: | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Check if summary exists in cache | ||
| cache_key = get_issue_summary_cache_key(group.id) | ||
| if cache.get(cache_key) is not None: | ||
| return | ||
|
|
||
| # Check if we're already generating the summary | ||
| lock_key, lock_name = get_issue_summary_lock_key(group.id) | ||
| lock = locks.get(lock_key, duration=5, name=lock_name) | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if lock.locked(): | ||
| return | ||
|
|
||
| # Generate summary (no automation) | ||
| if is_issue_eligible_for_seer_automation(group): | ||
| if not is_seer_scanner_rate_limited(group.project, group.organization): | ||
| generate_issue_summary_only.delay(group.id) | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| else: | ||
| # Event count >= 10: run automation | ||
| # Check seer_last_triggered first (long-term check to avoid re-running) | ||
| if group.seer_autofix_last_triggered is not None: | ||
| return | ||
|
|
||
| # Early returns for eligibility checks (cheap checks first) | ||
| if not is_issue_eligible_for_seer_automation(group): | ||
| return | ||
| if is_seer_scanner_rate_limited(group.project, group.organization): | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| start_seer_automation.delay(group.id) | ||
| # Check if we're already processing automation for this group | ||
| automation_dispatch_cache_key = f"seer-automation-dispatched:{group.id}" | ||
| if cache.get(automation_dispatch_cache_key) is not None: | ||
| return # Another process already dispatched automation | ||
|
|
||
| # Set cache with 5 minute TTL to prevent duplicate dispatches | ||
| cache.set(automation_dispatch_cache_key, True, timeout=300) | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Check if summary exists in cache | ||
| cache_key = get_issue_summary_cache_key(group.id) | ||
| if cache.get(cache_key) is not None: | ||
| # Summary exists, run automation directly | ||
| run_automation_for_group.delay(group.id) | ||
|
||
| else: | ||
| # No summary yet, generate summary + run automation in one go | ||
| start_seer_automation.delay(group.id) | ||
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Mihir-Mavalankar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| GROUP_CATEGORY_POST_PROCESS_PIPELINE = { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.