Skip to content

ref(crons): Reorganize incident creation / issue occurrence logic#13

Open
ShashankFC wants to merge 1 commit into
monitor-incident-refactor-beforefrom
monitor-incident-refactor-after
Open

ref(crons): Reorganize incident creation / issue occurrence logic#13
ShashankFC wants to merge 1 commit into
monitor-incident-refactor-beforefrom
monitor-incident-refactor-after

Conversation

@ShashankFC

Copy link
Copy Markdown
Contributor

Test 8

Summary by CodeRabbit

Release Notes

  • New Features
    • Implemented automatic incident creation and detection for monitor failures, respecting configurable failure thresholds.
    • Enhanced incident context with human-readable failure reason summaries, environment details, and tracking of last successful check-in times to aid in incident diagnosis and resolution.

✏️ Tip: You can customize this high-level summary in your review settings.


Replicated from ai-code-review-evaluation/sentry-coderabbit#8

…0528)

Since we'll be doing more with issue occurrences split out the concept
of incidents into it's own logic module, as well as incident_occurrence
into it's own module

Part of GH-80527
@ShashankFC ShashankFC requested a review from Copilot January 30, 2026 10:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the monitor incident creation and issue occurrence logic by extracting functionality from mark_failed.py into two new, more focused modules: incidents.py and incident_occurrence.py. The reorganization improves code modularity and separation of concerns.

Changes:

  • Extracted incident threshold checking logic into a new try_incident_threshold function in incidents.py
  • Moved issue occurrence creation logic into a new create_incident_occurrence function in incident_occurrence.py
  • Added SimpleCheckIn TypedDict to types.py for shared type definition

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/sentry/monitors/types.py Added SimpleCheckIn TypedDict to provide a shared type definition for stripped-down check-in objects
src/sentry/monitors/logic/mark_failed.py Simplified by removing incident creation logic and delegating to new try_incident_threshold function
src/sentry/monitors/logic/incidents.py New module containing extracted incident threshold checking and creation logic
src/sentry/monitors/logic/incident_occurrence.py New module containing extracted issue occurrence creation logic and helper functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


def get_failure_reason(failed_checkins: Sequence[SimpleCheckIn]):
"""
Builds a humam readible string from a list of failed check-ins.

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'humam' to 'human'.

Suggested change
Builds a humam readible string from a list of failed check-ins.
Builds a human readable string from a list of failed check-ins.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants