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

Conversation

Christinarlong
Copy link
Contributor

@Christinarlong Christinarlong commented Sep 30, 2024

Have the new tasks contain the logic and point other refs torward the new tasks.

issue ref (#73857 )

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 30, 2024
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 84.88372% with 39 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/sentry_apps/tasks/sentry_apps.py 86.13% 20 Missing and 8 partials ⚠️
src/sentry/tasks/sentry_apps.py 61.90% 8 Missing ⚠️
src/sentry/sentry_apps/tasks/service_hooks.py 92.00% 2 Missing ⚠️
src/sentry/tasks/servicehooks.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #78347      +/-   ##
==========================================
+ Coverage   78.13%   78.15%   +0.01%     
==========================================
  Files        7089     7088       -1     
  Lines      312501   312441      -60     
  Branches    51052    51083      +31     
==========================================
+ Hits       244172   244185      +13     
+ Misses      61958    61873      -85     
- Partials     6371     6383      +12     

@@ -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 🤷

@@ -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
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 🤷

@instrumented_task(
"sentry.sentry_apps.tasks.sentry_apps.send_resource_change_webhook", **TASK_OPTIONS
"sentry.sentry_apps.tasks.sentry_apps.send_process_resource_change_webhook", **TASK_OPTIONS
Copy link
Member

Choose a reason for hiding this comment

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

Renaming this task could result in dropped tasks as a worker with the new code could create a task that is received by a worker with the old code where this task name doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

F, thank you for catching this.

)


def send_webhooks(installation, event, **kwargs):
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 this will need typehints on the parameters to get through CI.

src/sentry/sentry_apps/tasks/sentry_apps.py Outdated Show resolved Hide resolved
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.

2 participants