feat(workflow_engine): Add in hook for producing occurrences from the stateful detector#8
Conversation
… 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. -->
Codoki PR ReviewSummary: Add occurrence hook, switch results to dict, ensure handler instantiation Issues (Critical & High only)
Showing top 2 issues. Critical: 0, High: 2. See inline suggestions for more. Key Feedback (click to expand)
Confidence: 3/5 — Needs work before merge (2 high · status: Requires changes) Sequence DiagramsequenceDiagram
participant Caller
participant Processor as process_detectors
participant Handler
participant Kafka as produce_occurrence_to_kafka
Caller->>Processor: process_detectors(data_packet, detectors)
loop for each detector
Processor->>Handler: evaluate(data_packet)
alt has results
loop for each result
alt result.result is IssueOccurrence or StatusChangeMessage
Processor->>Kafka: produce_occurrence_to_kafka(payload_type, occurrence/status_change, event_data)
end
end
Processor-->>Caller: append (detector, results)
end
Processor->>Handler: commit_state_updates()
end
Processor-->>Caller: results
React with 👍 or 👎 if you found this review useful. |
| ) -> list[DetectorEvaluationResult]: | ||
| # TODO: Implement | ||
| return [] | ||
| class MetricAlertDetectorHandler(StatefulDetectorHandler[QuerySubscriptionUpdate]): |
There was a problem hiding this comment.
| @@ -298,8 +295,10 @@ def evaluate_group_key_value( | |||
There was a problem hiding this comment.
🔷 Medium: Casting via PriorityLevel(new_status) assumes enum value parity; if DetectorPriorityLevel values diverge from PriorityLevel, this will raise or map to the wrong level. Using the enum name is safer when names are aligned.
| @@ -298,8 +295,10 @@ def evaluate_group_key_value( | |
| group_key, value, PriorityLevel[new_status.name] |
Mirrors ai-code-review-evaluation#10 for like-for-like benchmarking.
workflow-engine-stateful-detector-beforeworkflow-engine-stateful-detector-afterOriginal PR excerpt: