@@ -325,8 +325,13 @@ def handle_trigger_alerts(
325325 aggregation_value : float ,
326326 fired_incident_triggers : list [IncidentTrigger ],
327327 metrics_incremented : bool ,
328+ detector : Detector | None ,
328329 ) -> tuple [list [IncidentTrigger ], bool ]:
329330 # OVER/UNDER value trigger
331+ has_dual_processing_flag = features .has (
332+ "organizations:workflow-engine-metric-alert-dual-processing-logs" ,
333+ self .subscription .project .organization ,
334+ )
330335 alert_operator , resolve_operator = self .THRESHOLD_TYPE_OPERATORS [
331336 AlertRuleThresholdType (self .alert_rule .threshold_type )
332337 ]
@@ -339,15 +344,20 @@ def handle_trigger_alerts(
339344 "incidents.alert_rules.threshold.alert" ,
340345 tags = {"detection_type" : self .alert_rule .detection_type },
341346 )
342- if (
343- features .has (
344- "organizations:workflow-engine-metric-alert-dual-processing-logs" ,
345- self .subscription .project .organization ,
346- )
347- and not metrics_incremented
348- ):
349- metrics .incr ("dual_processing.alert_rules.fire" )
350- metrics_incremented = True
347+ if has_dual_processing_flag :
348+ if detector is not None :
349+ logger .info (
350+ "subscription_processor.alert_triggered" ,
351+ extra = {
352+ "rule_id" : self .alert_rule .id ,
353+ "detector_id" : detector .id ,
354+ "organization_id" : self .subscription .project .organization .id ,
355+ "project_id" : self .subscription .project .id ,
356+ },
357+ )
358+ if not metrics_incremented :
359+ metrics .incr ("dual_processing.alert_rules.fire" )
360+ metrics_incremented = True
351361 # triggering a threshold will create an incident and set the status to active
352362 incident_trigger = self .trigger_alert_threshold (trigger , aggregation_value )
353363 if incident_trigger is not None :
@@ -364,10 +374,17 @@ def handle_trigger_alerts(
364374 "incidents.alert_rules.threshold.resolve" ,
365375 tags = {"detection_type" : self .alert_rule .detection_type },
366376 )
367- if features .has (
368- "organizations:workflow-engine-metric-alert-dual-processing-logs" ,
369- self .subscription .project .organization ,
370- ):
377+ if has_dual_processing_flag :
378+ if detector is not None :
379+ logger .info (
380+ "subscription_processor.alert_triggered" ,
381+ extra = {
382+ "rule_id" : self .alert_rule .id ,
383+ "detector_id" : detector .id ,
384+ "organization_id" : self .subscription .project .organization .id ,
385+ "project_id" : self .subscription .project .id ,
386+ },
387+ )
371388 metrics .incr ("dual_processing.alert_rules.resolve" )
372389 incident_trigger = self .trigger_resolve_threshold (trigger , aggregation_value )
373390
@@ -615,7 +632,11 @@ def process_update(self, subscription_update: QuerySubscriptionUpdate) -> None:
615632 return
616633
617634 fired_incident_triggers , metrics_incremented = self .handle_trigger_alerts (
618- trigger , aggregation_value , fired_incident_triggers , metrics_incremented
635+ trigger ,
636+ aggregation_value ,
637+ fired_incident_triggers ,
638+ metrics_incremented ,
639+ detector ,
619640 )
620641
621642 if fired_incident_triggers :
0 commit comments