sentry icon indicating copy to clipboard operation
sentry copied to clipboard

ref(grouping): Pull code from `_save_aggregate_new` into helper functions

Open lobsterkatie opened this issue 1 year ago • 0 comments

As part of the on-going work cleaning up _save_aggreagte_new, in order to make the upcoming logic changes as easy to reason about and therefore as safe as possible, this pulls code not directly tied to the process of finding and creating grouphashes and assigning group ids to them into the following helper functions:

  • record_new_group_metrics - There's currently a lot of logic to collect these metrics, and likely to be even more in the future.

  • _get_group_processing_kwargs - This is the result of pulling all of the metadata-related code out of _save_aggregate_new and combining it with the logic in get_group_creation_kwargs. Before the removal of the hierarchical code this wasn't possible, as it was interleaved with the metadata logic. Now, however, the metadata-gathering code is independent of the rest and can be factored out. Also, I noticed that the group_creation_kwargs in _save_aggregate are in fact used not only when creating a group but also when updating it, hence the substitution of processing for creation.

  • check_for_group_creation_load_shed - Quick killswitch check.

  • add_group_id_to_grouphashes - With the hierarchical logic gone, the only difference between the new group branch and the existing group branch was that the latter filtered out any grouphashes which already had a group assigned. Though we know that in the new group branch that filter won't find anything - both grouphashes are new - it's safe to apply it in both branches.

  • check_for_category_mismatch - Though I couldn't find any instances of it happening in our logs, apparently it's possible for an error event's hash to match a non-error-type group.

lobsterkatie avatar Feb 09 '24 21:02 lobsterkatie