-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(code-mappings): Add code mappings task to post process #40882
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
Changes from 2 commits
ee08e24
308414c
799ce53
cc24c06
8af2d70
0522e91
a0e1ee4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -595,6 +595,37 @@ def process_rules(job: PostProcessJob) -> None: | |
return | ||
|
||
|
||
def process_code_mappings(job: PostProcessJob) -> None: | ||
if job["is_reprocessed"]: | ||
armenzg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
|
||
from sentry.tasks.derive_code_mappings import derive_code_mappings | ||
|
||
try: | ||
event = job["event"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the stacktraces available at this point? if all stacktraces match a code mapping we will not need to schedule anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be able to get stacktraces here like this. How would we check that it matches a code mapping? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking this more. We should not put the logic here, otherwise, we hit the DB for every event. |
||
project = event.project | ||
|
||
cache_key = f"code-mappings:{project.id}" | ||
project_queued = cache.get(cache_key) | ||
if project_queued is None: | ||
cache.set(cache_key, True, 3600) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use the project_id as the controlling mechanism here, we will need to control fetching the trees per org on the other task at the org id level. Otherwise, two events from two projects will trigger There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may make sense to add logging in case we want to debug the system: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added logging, good point! Let's talk about your other point tomorrow. Our worst case scenario here is an org with a large number of projects (N) that all get events each hour. I'm not sure how to prevent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What could happen within an hour for events for the same org:
We could check the cache key here (or an extra one) to only allow one event processed per hour per org for now so we can go live. I will work today on adding a way to track what is the current GH api limit and how to control when |
||
|
||
if project_queued or not features.has( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feature check will incorporate the option / killswitch added in https://github.com/getsentry/getsentry/pull/8777. We don't need to add separate logic here, which is pretty neat! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check this earlier? or only check once an hour? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this brings up a good point. We should add the killswitch check in |
||
"organizations:derive-code-mappings", event.project.organization | ||
): | ||
return | ||
|
||
if killswitch_matches_context( | ||
snigdhas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"post_process.derive-code-mappings", | ||
{"project_id": project.id}, | ||
): | ||
return | ||
derive_code_mappings.delay(project.organization_id, project.id, event.data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer only sending There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is alright since the only additional param is now the project ID. Otherwise, we would need to send the whole event to derive the project since the |
||
|
||
except Exception: | ||
logger.exception("Failed to set auto-assignment") | ||
|
||
|
||
def process_commits(job: PostProcessJob) -> None: | ||
if job["is_reprocessed"]: | ||
return | ||
|
@@ -777,6 +808,7 @@ def plugin_post_process_group(plugin_slug, event, **kwargs): | |
process_service_hooks, | ||
process_resource_change_bounds, | ||
process_plugins, | ||
process_code_mappings, | ||
process_similarity, | ||
update_existing_attachments, | ||
fire_error_processed, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this functionality work? Is there more documentation for this file? Is there a UI associated to modify kills switches on the fly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see WOR-2359