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

ref(querybuilder): Remove params from snuba modules #76198

Merged
merged 11 commits into from
Aug 16, 2024

Conversation

wmak
Copy link
Member

@wmak wmak commented Aug 14, 2024

  • Removes all the params from snuba modules for snuba_params instead

- Removes all the params from snuba modules for snuba_params instead
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 14, 2024
Copy link

codecov bot commented Aug 14, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
21641 1 21640 202
View the top 1 failed tests by shortest run time
tests.sentry.snuba.test_errors.ErrorsArithmeticTest�test_simple
Stack Traces | 5.38s run time
#x1B[1m#x1B[.../sentry/snuba/test_errors.py#x1B[0m:1762: in setUp
self.snuba_params = SnubaParams(
#x1B[1m#x1B[31m<string>#x1B[0m:11: in __init__
&&&
#x1B[1m#x1B[.../search/events/types.py#x1B[0m:97: in __post_init__
self.organization = self.projects[0].organization
#x1B[1m#x1B[31mE AttributeError: 'int' object has no attribute 'organization'#x1B[0m

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Copy link
Member Author

@wmak wmak left a comment

Choose a reason for hiding this comment

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

Commented on any actual changes, everything else should just be straightforward removing of params

@@ -391,26 +392,26 @@ def measure_span(op_tag):
serialized["options"] = options[project.id]
return result

def get_stats(self, project_ids, query):
def get_stats(self, projects, query):
Copy link
Member Author

Choose a reason for hiding this comment

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

Actual changes here, changed the param to a list of param objects so we don't need to hit the db again

def __init__(self, organization_id, discover_query):
self.projects = self.get_projects(organization_id, discover_query)
self.environments = self.get_environments(organization_id, discover_query)
def __init__(self, organization, discover_query):
Copy link
Member Author

Choose a reason for hiding this comment

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

Actual changes here, had to change the param from organization_id to the organization object.

And changed get_environments to return a list of objects instead of names

params={
"organization_id": alert_rule.organization.id,
"project_id": [project.id],
"granularity": granularity,
Copy link
Member Author

Choose a reason for hiding this comment

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

Granularity never did anything? not sure why it was passed here

Comment on lines +347 to +351
comp_query_params = snuba_params.copy()
assert comp_query_params.start is not None, "start is required"
assert comp_query_params.end is not None, "end is required"
comp_query_params.start -= comparison_delta
comp_query_params.end -= comparison_delta
Copy link
Member Author

Choose a reason for hiding this comment

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

I sorta hate this block 🤔 after the follow up PR to remove params entirely might add a utility to clean this up

@wmak wmak marked this pull request as ready for review August 15, 2024 16:21
@wmak wmak requested review from a team as code owners August 15, 2024 16:21
Copy link
Member

@shruthilayaj shruthilayaj left a comment

Choose a reason for hiding this comment

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

Okay, like you said, most of the changes were either not passing param anymore or passing that empty param dict to the query builders, so that was straightforward. I also looked at the function signatures you explicitly called out, those looked good to me too.
🚀

wmak added a commit that referenced this pull request Aug 15, 2024
…n easier

- The plan:
	- Update getsentry's call to discover.query to use this function
	  instead
	- Merge #76198
	- Update getsentry back to using discover.query and remove this
	  function
wmak added a commit that referenced this pull request Aug 15, 2024
…n easier (#76279)

- The plan:
- Update getsentry's call to discover.query to use this function instead
	- Merge #76198
- Update getsentry back to using discover.query and remove this function
@wmak wmak merged commit 3e923c3 into master Aug 16, 2024
48 checks passed
@wmak wmak deleted the wmak/ref/remove-params-from-modules branch August 16, 2024 18:02
@ceorourke ceorourke added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Aug 16, 2024
@getsentry-bot
Copy link
Contributor

PR reverted: f4a5282

getsentry-bot added a commit that referenced this pull request Aug 16, 2024
This reverts commit 3e923c3.

Co-authored-by: ceorourke <29959063+ceorourke@users.noreply.github.com>
wmak added a commit that referenced this pull request Aug 27, 2024
- Removes all the params from snuba modules for snuba_params instead
- Reintroduces #76198 which had
to be reverted because of
https://sentry.sentry.io/issues/5721375935/events/37f53d54aa0741d3becea6f75399f1d6/?project=1&referrer=issue-list&statsPeriod=90d
- Which was fixed in fe1d578 and a test
added to avoid this again in the future
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 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 Trigger: Revert Add to a merged PR to revert it (skips CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants