Skip to content

Conversation

@akshayutture-augment
Copy link

… stateful detector (#80168)

This adds a hook that can be implemented to produce an occurrence
specific to the detector that is subclassing the StatefulDetector.

Also change the signature of evaluate to return a dict keyed by groupkey
instead of a list. This helps avoid the chance of duplicate results for
the same group key.

<!-- Describe your PR here. -->
Copilot AI review requested due to automatic review settings November 14, 2025 22:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


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

) -> list[DetectorEvaluationResult]:
# TODO: Implement
return []
class MetricAlertDetectorHandler(StatefulDetectorHandler[QuerySubscriptionUpdate]):
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The MetricAlertDetectorHandler class now inherits from StatefulDetectorHandler but provides no implementation for the required abstract methods (get_dedupe_value, get_group_key_values, and build_occurrence_and_event_data). This will cause runtime errors when instantiated. Either provide concrete implementations or add a comment explaining why this is intentionally incomplete.

Suggested change
class MetricAlertDetectorHandler(StatefulDetectorHandler[QuerySubscriptionUpdate]):
class MetricAlertDetectorHandler(StatefulDetectorHandler[QuerySubscriptionUpdate]):
"""
Placeholder for a future stateful detector handler for metric alerts.
This class intentionally does not implement the required abstract methods
(get_dedupe_value, get_group_key_values, build_occurrence_and_event_data)
and should not be instantiated until the abstraction is complete.
"""

Copilot uses AI. Check for mistakes.
event_data,
)
occurrence_2, event_data_2 = build_mock_occurrence_and_event(
detector.detector_handler, "group_2", 6, PriorityLevel.HIGH
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The value parameter passed to build_mock_occurrence_and_event should be 10, not 6, to match the group_vals data packet on line 177 where 'group_2': 10. This inconsistency could mask bugs in the occurrence generation logic.

Suggested change
detector.detector_handler, "group_2", 6, PriorityLevel.HIGH
detector.detector_handler, "group_2", 10, PriorityLevel.HIGH

Copilot uses AI. Check for mistakes.
self.enqueue_state_update(group_key, is_active, new_status)
event_data = None
result = None
result: StatusChangeMessage | IssueOccurrence
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

[nitpick] The type annotation for 'result' is redundant since it's immediately assigned in both branches of the if-else statement. Consider removing this line or initializing result with a default value.

Suggested change
result: StatusChangeMessage | IssueOccurrence
result

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