Skip to content

chore(ACI): Add 1:1 metrics for dual processing #91840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions src/sentry/incidents/subscription_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,21 @@ def process_update(self, subscription_update: QuerySubscriptionUpdate) -> None:
if has_anomaly(
potential_anomaly, trigger.label
) and not self.check_trigger_matches_status(trigger, TriggerStatus.ACTIVE):
metrics.incr(
"incidents.alert_rules.threshold.alert",
tags={"detection_type": self.alert_rule.detection_type},
)
if features.has(
"organizations:workflow-engine-metric-alert-dual-processing-logs"
):
metrics.incr(
"incidents.alert_rules.threshold.alert",
tags={
"detection_type": self.alert_rule.detection_type,
"organization_id": self.alert_rule.organization_id,
},
)
else:
metrics.incr(
"incidents.alert_rules.threshold.alert",
tags={"detection_type": self.alert_rule.detection_type},
)
incident_trigger = self.trigger_alert_threshold(
trigger, aggregation_value
)
Expand All @@ -520,10 +531,21 @@ def process_update(self, subscription_update: QuerySubscriptionUpdate) -> None:
and self.active_incident
and self.check_trigger_matches_status(trigger, TriggerStatus.ACTIVE)
):
metrics.incr(
"incidents.alert_rules.threshold.resolve",
tags={"detection_type": self.alert_rule.detection_type},
)
if features.has(
"organizations:workflow-engine-metric-alert-dual-processing-logs"
):
metrics.incr(
"incidents.alert_rules.threshold.resolve",
tags={
"detection_type": self.alert_rule.detection_type,
"organization_id": self.alert_rule.organization_id,
},
)
else:
metrics.incr(
"incidents.alert_rules.threshold.resolve",
tags={"detection_type": self.alert_rule.detection_type},
)
incident_trigger = self.trigger_resolve_threshold(
trigger, aggregation_value
)
Expand Down
9 changes: 9 additions & 0 deletions src/sentry/workflow_engine/processors/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,14 @@ def process_workflows(event_data: WorkflowEventData) -> set[Workflow]:
"detector_type": detector.type,
},
)
if features.has("organizations:workflow-engine-metric-alert-dual-processing-logs"):
# in order to check if workflow engine is firing 1:1 with the old system, we must only count once rather than each action
metrics.incr(
"workflow_engine.process_workflows.fired_actions",
tags={
"detector_type": detector.type,
"organization_id": detector.project.organization_id,
},
)
Copy link
Contributor

@saponifi3d saponifi3d May 16, 2025

Choose a reason for hiding this comment

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

thoughts on pulling out the org_id and setting the tag on every metric? something like:

organization_id = None
if features.has("organizations:workflow-engine-metric-alert-dual-processing-logs"):
    organization_id = detector.project.organization_id
    
metrics.incr(
    "workflow_engine.process_workflows.triggered_actions",
    amount=len(actions),
    tags={"detector_type": detector.type, "organization_id": organization_id},
)

Copy link
Member Author

Choose a reason for hiding this comment

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

I am making this a separate metric because I don't want to have the amount being set to the number of actions as that's not how we track it in the existing system.

Copy link
Contributor

@saponifi3d saponifi3d May 16, 2025

Choose a reason for hiding this comment

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

sorry for the confusion, the action one is just meant to illustrate an existing metric decorated with the organization id.

mostly just thinking that we could just add the organization id to all the existing metrics if we pull out the check for the feature and assign the org id to a separate variable. (very similar to the comment that dan had left)

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 all the other metrics in this function pass an amount that's possibly larger than 1, and I only ever want to count a metric issue firing or resolving once otherwise the metrics might not line up


return triggered_workflows
Loading