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

chore(sentry apps): Move logic to new Sentry App tasks #78347

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
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
4 changes: 2 additions & 2 deletions src/sentry/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
[
# basic tasks that must be passed models still
"sentry.tasks.process_buffer.process_incr",
"sentry.tasks.process_resource_change_bound",
"sentry.tasks.sentry_apps.send_alert_event",
"sentry.sentry_apps.tasks.sentry_apps.process_resource_change_bound",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Q: what is pickling/pickle tasks -> Like my google research has told me pickle is a serializer for celery tasks. So is pickling when you pass in a too complex object to get serialized? Is that bad because serializing an object is really expensive?

Copy link
Member

Choose a reason for hiding this comment

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

pickle is stdlib library to serialize and deserialize python objects. We currently use it with celery so that any parameter that could end up in a task works. Pickle isn't great because it creates a few problems:

  1. ORM entities can become stale while in the queue message
  2. Deserializing python objects off of the network can lead to arbitrary code execution.

We've been trying to not introduce new tasks that rely on pickle so that in the future we can remove pickle support and only json encode task parameters.

Normally we shouldn't add to this list, but we're just moving things around so 🤷

"sentry.sentry_apps.tasks.sentry_apps.send_alert_event",
"sentry.tasks.unmerge",
"src.sentry.notifications.utils.async_send_notification",
# basic tasks that can already deal with primary keys passed
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/receivers/outbox/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from sentry.receivers.outbox import maybe_process_tombstone
from sentry.relocation.services.relocation_export.service import region_relocation_export_service
from sentry.sentry_apps.models.sentry_app import SentryApp
from sentry.tasks.sentry_apps import clear_region_cache
from sentry.sentry_apps.tasks.sentry_apps import clear_region_cache

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/receivers/sentry_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from sentry.models.team import Team
from sentry.sentry_apps.logic import consolidate_events
from sentry.sentry_apps.services.app import RpcSentryAppInstallation, app_service
from sentry.sentry_apps.tasks.sentry_apps import build_comment_webhook, workflow_notification
from sentry.signals import (
comment_created,
comment_deleted,
Expand All @@ -22,7 +23,6 @@
issue_resolved,
issue_unresolved,
)
from sentry.tasks.sentry_apps import build_comment_webhook, workflow_notification
from sentry.users.models.user import User
from sentry.users.services.user import RpcUser

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/rules/actions/notify_event_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sentry.rules.base import CallbackFuture
from sentry.sentry_apps.api.serializers.app_platform_event import AppPlatformEvent
from sentry.sentry_apps.services.app import RpcSentryAppService, app_service
from sentry.tasks.sentry_apps import notify_sentry_app
from sentry.sentry_apps.tasks.sentry_apps import notify_sentry_app
from sentry.utils import json, metrics
from sentry.utils.forms import set_field_choices

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/rules/actions/sentry_apps/notify_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
RpcSentryAppEventData,
app_service,
)
from sentry.tasks.sentry_apps import notify_sentry_app
from sentry.sentry_apps.tasks.sentry_apps import notify_sentry_app

ValidationError = serializers.ValidationError

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/sentry_apps/installations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation
from sentry.sentry_apps.models.sentry_app_installation_token import SentryAppInstallationToken
from sentry.sentry_apps.services.hook import hook_service
from sentry.tasks.sentry_apps import installation_webhook
from sentry.sentry_apps.tasks.sentry_apps import installation_webhook
from sentry.users.models.user import User
from sentry.users.services.user.model import RpcUser
from sentry.utils import metrics
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/sentry_apps/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
from sentry.sentry_apps.models.sentry_app_component import SentryAppComponent
from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation
from sentry.tasks.sentry_apps import create_or_update_service_hooks_for_sentry_app
from sentry.sentry_apps.tasks.sentry_apps import create_or_update_service_hooks_for_sentry_app
from sentry.users.models.user import User
from sentry.users.services.user.model import RpcUser
from sentry.utils.sentry_apps.service_hook_manager import (
Expand Down
Loading
Loading