Skip to content

Conversation

saponifi3d
Copy link
Contributor

Description

As we were implementing DataConditionHandlers, I realized we didn't have a way to filter each handler in an API for the UI. This allow users to select the type of handler they want, and then configure it.

To address this, adding a static type to the condition handlers to match where in the product they'll be used;

  • detector triggers (used for setting thresholds and then results give detector states)
  • workflow triggers (used for workflow conditions, to evaluate if the issues are new / regressed, etc)
  • action filters (used to decide if we want to invoke an action in a workflow or not, if a tag is set or a priority needs to be met)

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 10, 2025
…he handlers in APIs, allowing us to generate dropdowns for each product area (detectors, workflows, actions)
@saponifi3d saponifi3d force-pushed the jcallender/aci/data-conditions-api-spike branch 2 times, most recently from c2d790a to f39a0b5 Compare January 10, 2025 22:35
…will allow us to have filtered dropdowns in the ui
@saponifi3d saponifi3d force-pushed the jcallender/aci/data-conditions-api-spike branch from f39a0b5 to 2c28d43 Compare January 10, 2025 22:43
@saponifi3d saponifi3d marked this pull request as ready for review January 10, 2025 23:05
@saponifi3d saponifi3d requested a review from a team as a code owner January 10, 2025 23:05


@condition_handler_registry.register(Condition.EVERY_EVENT)
class EveryEventConditionHandler(DataConditionHandler[WorkflowJob]):
type: DataConditionHandlerType = DataConditionHandlerType.WORKFLOW_TRIGGER
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cathteng can you confirm we need this condition handler? i think we might be able to remove it since it always evaluates as truthy (if we don't have a condition in a condition group that also evaluates as truthy).

Copy link
Member

Choose a reason for hiding this comment

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

i think you might be right, this was added in the past by default for issue alerts with no conditions in the WHEN 😬 but now we have a default evaluation for it

Copy link
Member

@cathteng cathteng left a comment

Choose a reason for hiding this comment

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

just these two should be workflow triggers!

saponifi3d and others added 2 commits January 10, 2025 15:12
…_handler.py

Co-authored-by: Cathy Teng <70817427+cathteng@users.noreply.github.com>
…iority_issue_handler.py

Co-authored-by: Cathy Teng <70817427+cathteng@users.noreply.github.com>
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #83276      +/-   ##
==========================================
+ Coverage   87.53%   87.54%   +0.01%     
==========================================
  Files        9405     9409       +4     
  Lines      537590   537741     +151     
  Branches    21175    21120      -55     
==========================================
+ Hits       470574   470770     +196     
+ Misses      66668    66623      -45     
  Partials      348      348              

@saponifi3d saponifi3d requested review from cathteng and a team January 14, 2025 22:56
@@ -55,6 +62,10 @@ def bulk_get_query_object(data_sources) -> dict[int, T | None]:


class DataConditionHandler(Generic[T]):
@abstractproperty
def type(self) -> DataConditionHandlerType:
Copy link
Member

Choose a reason for hiding this comment

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

is it weird that to use this type, we'll have to initialize the handler? i'm finding this with using abstract properties for enforcing data conditions json schemas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to use the ClassVar - it's nice that i can access it statically, but yeah, the typing isn't great or there needs to be a default value. I'll stick with ClassVar + default for now for consistency and cause it has the best general mixture of type safety and customization.

…s_handler.py

Co-authored-by: Cathy Teng <70817427+cathteng@users.noreply.github.com>
@saponifi3d saponifi3d enabled auto-merge (squash) January 15, 2025 22:19
@saponifi3d saponifi3d merged commit 792981b into master Jan 15, 2025
49 checks passed
@saponifi3d saponifi3d deleted the jcallender/aci/data-conditions-api-spike branch January 15, 2025 22:43
andrewshie-sentry pushed a commit that referenced this pull request Jan 22, 2025
…onditionHandler (#83276)

## Description
As we were implementing DataConditionHandlers, I realized we didn't have
a way to filter each handler in an API for the UI. This allow users to
select the type of handler they want, and then configure it.

To address this, adding a static type to the condition handlers to match
where in the product they'll be used;
- detector triggers (used for setting thresholds and then results give
detector states)
- workflow triggers (used for workflow conditions, to evaluate if the
issues are new / regressed, etc)
- action filters (used to decide if we want to invoke an action in a
workflow or not, if a tag is set or a priority needs to be met)

---------

Co-authored-by: Cathy Teng <70817427+cathteng@users.noreply.github.com>
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants