Skip to content

Webhooks for alerts #309

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 10 commits into from
Jan 27, 2025
Merged

Webhooks for alerts #309

merged 10 commits into from
Jan 27, 2025

Conversation

f-wright
Copy link
Contributor

Webhooks have been recently added as an action option for Groundlight, this PR makes them accessible through the SDK.

@@ -46,7 +48,7 @@
from .client import DEFAULT_REQUEST_TIMEOUT, Groundlight, logger


class ExperimentalApi(Groundlight):
class ExperimentalApi(Groundlight): # pylint: disable=too-many-public-methods
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if there's a different way you'd prefer I solve this -- it seems best to keep the method here so I just disabled it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I prefer this. The pylint suggestion is probably to group up the methods under subclasses, but I think that's unnecessary at this time

@f-wright f-wright marked this pull request as ready for review January 18, 2025 00:35
@f-wright f-wright requested a review from brandon-wada January 18, 2025 00:36
Copy link
Collaborator

@brandon-wada brandon-wada left a comment

Choose a reason for hiding this comment

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

Looks great!

@@ -46,7 +48,7 @@
from .client import DEFAULT_REQUEST_TIMEOUT, Groundlight, logger


class ExperimentalApi(Groundlight):
class ExperimentalApi(Groundlight): # pylint: disable=too-many-public-methods
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I prefer this. The pylint suggestion is probably to group up the methods under subclasses, but I think that's unnecessary at this time

self,
detector: Union[str, Detector],
name,
condition: Condition,
actions: Union[Action, List[Action], ActionList],
actions: Optional[Union[Action, List[Action], ActionList]] = None,
webhook_actions: Optional[Union[WebhookAction, List[WebhookAction]]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

A little bit of humming and hawing here.

This outcome of having webhook_actions being separate from actions is non-intuitive for users. The natural design here is that we have many types of actions that are subclasses of Action, webhook_actions among them.

The reason this is not laid out this way is because we didn't have that design to begin with and built significant infra around a different layout. That makes it unreasonable to add webhook_actions as a subclass of actions here in the SDK because the SDK by design is tightly coupled with our other infra.

TLDR; we started painting ourselves into this corner a long time ago, and I don't like this corner. It works though and nothing needs to change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree with all of that. It is confusing for the user, but it seems like this makes the most sense in terms of keeping the SDK in line with the backend infra.

If we do want to decouple the SDK from the rest of the infra in this way, I think it could be fine to create a convenience method for the users that allows them to submit a single list of actions, and we can split them into separate "actions" and "webhook actions" before sending to the back end.

@f-wright f-wright merged commit 2eceb62 into main Jan 27, 2025
9 checks passed
@f-wright f-wright deleted the webhooks-for-alerts-v2 branch January 27, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants