ref(crons): Reorganize incident creation / issue occurrence logic#14
Open
ShashankFC wants to merge 1 commit intomonitor-incident-refactor-beforefrom
Open
ref(crons): Reorganize incident creation / issue occurrence logic#14ShashankFC wants to merge 1 commit intomonitor-incident-refactor-beforefrom
ShashankFC wants to merge 1 commit intomonitor-incident-refactor-beforefrom
Conversation
…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
Greptile SummaryThis PR refactors the monitor incident and occurrence creation logic by extracting code from Key Changes:
Issues Found:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Consumer as Monitor Consumer
participant MF as mark_failed.py
participant TIT as try_incident_threshold<br/>(incidents.py)
participant CIO as create_incident_occurrence<br/>(incident_occurrence.py)
participant DB as Database
participant Kafka as Kafka
Consumer->>MF: mark_failed(failed_checkin, ts, received)
MF->>MF: Get failure_issue_threshold from config
MF->>MF: Calculate next check-in times
MF->>DB: Update MonitorEnvironment timestamps
alt Update successful
MF->>TIT: try_incident_threshold(failed_checkin, threshold, received)
TIT->>TIT: Check monitor_env.status
alt Status is OK/ACTIVE
TIT->>DB: Query previous check-ins
TIT->>TIT: Check if threshold reached
alt Threshold reached
TIT->>DB: Set status to ERROR
TIT->>DB: Create/get MonitorIncident
end
else Status is ERROR
TIT->>DB: Get active_incident
end
alt Incident exists and not muted
TIT->>DB: Query MonitorCheckIn objects
loop For each check-in
TIT->>CIO: create_incident_occurrence(checkins, checkin, incident, received)
CIO->>CIO: Build IssueOccurrence with evidence
CIO->>CIO: Build event_data with context
CIO->>Kafka: produce_occurrence_to_kafka()
end
end
TIT->>TIT: Send monitor_environment_failed signal
TIT-->>MF: Return True
else Update failed
MF-->>Consumer: Return False
end
MF-->>Consumer: Return result
|
|
|
||
| def get_failure_reason(failed_checkins: Sequence[SimpleCheckIn]): | ||
| """ | ||
| Builds a humam readible string from a list of failed check-ins. |
There was a problem hiding this comment.
syntax: Typo: "humam readible" should be "human readable"
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. |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/sentry/monitors/logic/incident_occurrence.py
Line: 132:132
Comment:
**syntax:** Typo: "humam readible" should be "human readable"
```suggestion
Builds a human readable string from a list of failed check-ins.
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test 8
Replicated from ai-code-review-evaluation/sentry-greptile#8