ref(grouping): Pull code from `_save_aggregate_new` into helper functions
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_newand combining it with the logic inget_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 thegroup_creation_kwargsin_save_aggregateare in fact used not only when creating a group but also when updating it, hence the substitution ofprocessingforcreation. -
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.