Skip to content

ref(grouping): Move background grouping code to grouping module#62856

Merged
lobsterkatie merged 5 commits intomasterfrom
kmclb-move-background-grouping-code
Jan 10, 2024
Merged

ref(grouping): Move background grouping code to grouping module#62856
lobsterkatie merged 5 commits intomasterfrom
kmclb-move-background-grouping-code

Conversation

@lobsterkatie
Copy link
Copy Markdown
Member

@lobsterkatie lobsterkatie commented Jan 9, 2024

This moves the code handling background grouping (and the associated tests) into the grouping module, as part of a larger refactor.

No other code changes made, though I did add a missing test and modify an existing one to spy on rather than mock _calculate_background_grouping, both in order to placate codecov.

@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Jan 9, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: src/sentry/event_manager.py

Function Unhandled Issue
has_resolution TypeError: '>=' not supported between instances of 'datetime.datetime' and 'str' ...
Event Count: 4

Did you find this useful? React with a 👍 or 👎

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 9, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (57107d8) 81.33% compared to head (bb73c69) 81.33%.
Report is 12 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #62856   +/-   ##
=======================================
  Coverage   81.33%   81.33%           
=======================================
  Files        5202     5202           
  Lines      230449   230476   +27     
  Branches    39824    39830    +6     
=======================================
+ Hits       187441   187466   +25     
- Misses      37260    37261    +1     
- Partials     5748     5749    +1     
Files Coverage Δ
...entry/integrations/slack/message_builder/issues.py 85.27% <100.00%> (+0.15%) ⬆️
...ions/slack/message_builder/notifications/digest.py 100.00% <100.00%> (ø)
src/sentry/integrations/slack/webhooks/action.py 85.25% <ø> (ø)
src/sentry/options/defaults.py 100.00% <ø> (ø)
static/app/views/organizationContextContainer.tsx 86.41% <ø> (+0.87%) ⬆️
...settings/projectPerformance/projectPerformance.tsx 85.71% <ø> (ø)
src/sentry/grouping/ingest.py 86.84% <94.73%> (+2.35%) ⬆️

... and 2 files with indirect coverage changes

@lobsterkatie lobsterkatie force-pushed the kmclb-move-background-grouping-code branch from d9d4265 to bb73c69 Compare January 9, 2024 22:03
@lobsterkatie lobsterkatie marked this pull request as ready for review January 9, 2024 22:39
@lobsterkatie lobsterkatie requested review from a team as code owners January 9, 2024 22:39
@lobsterkatie lobsterkatie merged commit fe73206 into master Jan 10, 2024
@lobsterkatie lobsterkatie deleted the kmclb-move-background-grouping-code branch January 10, 2024 00:17
trillville pushed a commit that referenced this pull request Jan 19, 2024
…2856)

This moves the code handling background grouping (and the associated tests) into the `grouping` module, as part of a larger refactor. 

No other code changes made, though I did add a missing test and modify an existing one to spy on rather than mock `_calculate_background_grouping`, both in order to placate codecov.
lobsterkatie added a commit that referenced this pull request Jan 24, 2024
Background grouping is a safe way for us to measure the performance of a new grouping config - we run the grouping algorithm with that config, time it, and then toss the results, so the change doesn't affect any events' eventual grouping. 

Currently, there is an option controlling whether to run this test before or after the main hash calculations, presumably because it has the possibility of modifying the event. Or rather, it _had_ the possibility of modifying the event. In #62856, which moved the background grouping functions to the `grouping` module, a change was made so that background grouping is applied to a copy of the event rather than the event itself. It therefore no longer matters whether it happens before or after the main calculations. (It's blocking either way, so that's not a consideration here.)

This refactors the code such that background grouping is always run before the main calculations. (I chose before rather than after because that way it's not mixed in with other logic having to do with the main grouping process.) For safety, it doesn't yet remove the option from `defaults.py`, but it does mark it as unused. (The removal will come in a future PR.) 

In addition, this renames the background grouping function from `run_background_grouping` to `maybe_run_background_grouping` (to reflect the fact that background grouping only runs on a fraction of events) and fixes up the function's docstring.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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