Skip to content
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

fix(aci milestone 3): updates to dual writing data conditions #83275

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mifu67
Copy link
Contributor

@mifu67 mifu67 commented Jan 10, 2025

When dual writing AlertRuleTriggers to the ACI tables, we must create 2 data conditions:

  1. The "detector trigger," which compares against the trigger threshold value and returns a DetectorPriorityLevel as its condition result
  2. The "action filter," which checks the detector status and returns True as its condition result. Each of these "action filters" has its own DataConditionGroup as well, which is linked back to the legacy alert rule's associated workflow.

Implement this paradigm. Also add logic to automatically set a resolve threshold if it's not set by the user on the legacy alert rule.

@mifu67 mifu67 requested a review from a team as a code owner January 10, 2025 22:18
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 10, 2025
Copy link

codecov bot commented Jan 10, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
23481 1 23480 272
View the top 1 failed tests by shortest run time
tests.snuba.tagstore.test_tagstore_backend.TagStorageTest::test_get_group_tag_key_generic
Stack Traces | 7.86s run time
#x1B[1m#x1B[31mtests/conftest.py#x1B[0m:32: in unclosed_files
    assert frozenset(psutil.Process().open_files()) == fds
#x1B[1m#x1B[31mE   AssertionError: assert frozenset({po...flags=32768)}) == frozenset()#x1B[0m
#x1B[1m#x1B[31mE     #x1B[0m
#x1B[1m#x1B[31mE     Extra items in the left set:#x1B[0m
#x1B[1m#x1B[31mE     popenfile(path='.../sentry/sentry/.venv/lib/python3.12....../site-packages/certifi/cacert.pem', fd=47, position=155648, mode='r', flags=32768)#x1B[0m
#x1B[1m#x1B[31mE     #x1B[0m
#x1B[1m#x1B[31mE     Full diff:#x1B[0m
#x1B[1m#x1B[31mE     - frozenset()#x1B[0m
#x1B[1m#x1B[31mE     ?           ^#x1B[0m
#x1B[1m#x1B[31mE     + frozenset({#x1B[0m
#x1B[1m#x1B[31mE     ?           ^#x1B[0m
#x1B[1m#x1B[31mE     +     popenfile(path='.../sentry/sentry/.venv/lib/python3.12....../site-packages/certifi/cacert.pem', fd=47, position=155648, mode='r', flags=32768),#x1B[0m
#x1B[1m#x1B[31mE     + })#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@@ -120,13 +138,75 @@ def migrate_metric_data_condition(
alert_rule_trigger_data_condition = AlertRuleTriggerDataCondition.objects.create(
alert_rule_trigger=alert_rule_trigger, data_condition=data_condition
)
return data_condition, alert_rule_trigger_data_condition
return detector_trigger, data_condition, alert_rule_trigger_data_condition
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 it might be better for us to do the detector's data_condition migrations with the detector and the workflow's action filters in another. that's mostly just a nit to have this be a little clearer or help incase we have issues with the migration (like a workflow migrated correctly, but not a detector, we could then reuse the migrate detector method to just migrate the detector and all of it's associated conditions)

src/sentry/workflow_engine/migration_helpers/alert_rule.py Outdated Show resolved Hide resolved
src/sentry/workflow_engine/migration_helpers/alert_rule.py Outdated Show resolved Hide resolved
src/sentry/workflow_engine/migration_helpers/alert_rule.py Outdated Show resolved Hide resolved
Comment on lines +203 to +208
detector_trigger = DataCondition.objects.create(
comparison=resolve_threshold,
condition_result=DetectorPriorityLevel.OK,
type=threshold_type,
condition_group=detector_data_condition_group,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants