Skip to content

Commit 3a9cf30

Browse files
committed
unify naming schemes a little more -- starting to see the next pr
1 parent 22b528c commit 3a9cf30

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/sentry/workflow_engine/handlers/detector/stateful.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,11 @@ def evaluate(
428428
# TODO ensure this is not a duplicate packet or reprocessing
429429

430430
value = self.extract_value(data_packet)
431-
condition_evaluation, new_priority = self._evaluation_detector_conditions(value)
431+
is_condition_group_met, new_priority = self._evaluation_detector_conditions(value)
432432
state = self.state_manager.get_state_data([None])[None]
433433

434-
if not condition_evaluation or state.status == new_priority:
434+
is_status_changed = state.status != new_priority
435+
if not is_condition_group_met or not is_status_changed:
435436
# If the condition is not met or the status is not the same, nothing to do.
436437
return None
437438

@@ -448,10 +449,10 @@ def evaluate(
448449
self.state_manager.enqueue_counter_reset()
449450
else:
450451
detector_occurrence, event_data = self.create_occurrence(
451-
condition_evaluation, data_packet, new_priority
452+
is_condition_group_met, data_packet, new_priority
452453
)
453454
detector_result = self._create_decorated_issue_occurrence(
454-
detector_occurrence, condition_evaluation, new_priority
455+
detector_occurrence, is_condition_group_met, new_priority
455456
)
456457

457458
return {
@@ -535,15 +536,16 @@ def evaluate_group_key_value(
535536
metrics.incr("workflow_engine.detector.skipping_invalid_condition_group")
536537
return None
537538

538-
new_status = DetectorPriorityLevel.OK
539-
is_condition_group_met, new_status = self._evaluation_detector_conditions(value)
539+
new_priority = DetectorPriorityLevel.OK
540+
is_condition_group_met, new_priority = self._evaluation_detector_conditions(value)
541+
is_status_changed = state_data.status != new_priority
540542

541-
if state_data.status == new_status or not is_condition_group_met:
543+
if not is_status_changed or not is_condition_group_met:
542544
return None
543545

544546
# Update the counter for the new status
545547
updated_threshold_count = self._increment_detector_thresholds(
546-
state_data, new_status, group_key
548+
state_data, new_priority, group_key
547549
)
548550

549551
breached_threshold = self._has_breached_threshold(updated_threshold_count)

tests/sentry/workflow_engine/processors/test_detector.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ def test_multi(self):
311311
counter_updates={
312312
**{level: None for level in handler._thresholds},
313313
DetectorPriorityLevel.OK: 5,
314-
DetectorPriorityLevel.MEDIUM: 1,
315314
},
316315
)
317316
handler.state_manager.enqueue_dedupe_update(key_1, state_data_1.dedupe_value)

0 commit comments

Comments
 (0)