-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(discover): Add the snql feature flag to eventsv2 #29395
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 all commits
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 |
|---|---|---|
|
|
@@ -41,10 +41,12 @@ def setUp(self): | |
| self.min_ago = iso_format(before_now(minutes=1)) | ||
| self.two_min_ago = iso_format(before_now(minutes=2)) | ||
| self.transaction_data = load_data("transaction", timestamp=before_now(minutes=1)) | ||
| self.features = {} | ||
|
|
||
| def do_request(self, query, features=None): | ||
| if features is None: | ||
| features = {"organizations:discover-basic": True} | ||
| features.update(self.features) | ||
| self.login_as(user=self.user) | ||
| url = reverse( | ||
| "sentry-api-0-organization-eventsv2", | ||
|
|
@@ -133,8 +135,10 @@ def test_invalid_search_terms(self): | |
| ) | ||
|
|
||
| @mock.patch("sentry.snuba.discover.raw_query") | ||
| def test_handling_snuba_errors(self, mock_query): | ||
| @mock.patch("sentry.snuba.discover.raw_snql_query") | ||
| def test_handling_snuba_errors(self, mock_snql_query, mock_query): | ||
| mock_query.side_effect = RateLimitExceeded("test") | ||
| mock_snql_query.side_effect = RateLimitExceeded("test") | ||
|
|
||
| project = self.create_project() | ||
|
|
||
|
|
@@ -148,13 +152,15 @@ def test_handling_snuba_errors(self, mock_query): | |
| assert response.data["detail"] == TIMEOUT_ERROR_MESSAGE | ||
|
|
||
| mock_query.side_effect = QueryExecutionError("test") | ||
| mock_snql_query.side_effect = QueryExecutionError("test") | ||
|
|
||
| query = {"field": ["id", "timestamp"], "orderby": ["-timestamp", "-id"]} | ||
| response = self.do_request(query) | ||
| assert response.status_code == 500, response.content | ||
| assert response.data["detail"] == "Internal error. Your query failed to run." | ||
|
|
||
| mock_query.side_effect = QueryIllegalTypeOfArgument("test") | ||
| mock_snql_query.side_effect = QueryIllegalTypeOfArgument("test") | ||
|
|
||
| query = {"field": ["id", "timestamp"], "orderby": ["-timestamp", "-id"]} | ||
| response = self.do_request(query) | ||
|
|
@@ -1412,6 +1418,7 @@ def test_user_misery_alias_field_with_project_threshold(self): | |
| "transaction", | ||
| "user_misery()", | ||
| ], | ||
| "orderby": "user_misery()", | ||
| "query": "event.type:transaction", | ||
| "project": [project.id], | ||
| } | ||
|
|
@@ -1422,8 +1429,8 @@ def test_user_misery_alias_field_with_project_threshold(self): | |
| assert len(response.data["data"]) == 3 | ||
| data = response.data["data"] | ||
| assert abs(data[0]["user_misery"] - 0.04916) < 0.0001 | ||
| assert abs(data[1]["user_misery"] - 0.06586) < 0.0001 | ||
| assert abs(data[2]["user_misery"] - 0.05751) < 0.0001 | ||
| assert abs(data[1]["user_misery"] - 0.05751) < 0.0001 | ||
| assert abs(data[2]["user_misery"] - 0.06586) < 0.0001 | ||
|
Member
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. Thoughts on using
Member
Author
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. TIL, we can update in a future PR cc @shruthilayaj (as a btw not saying you're the one who has to do it)
Member
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. ooh nice, good to know 👍 |
||
|
|
||
| query["query"] = "event.type:transaction user_misery():>0.050" | ||
|
|
||
|
|
@@ -1434,8 +1441,8 @@ def test_user_misery_alias_field_with_project_threshold(self): | |
| assert response.status_code == 200, response.content | ||
| assert len(response.data["data"]) == 2 | ||
| data = response.data["data"] | ||
| assert abs(data[0]["user_misery"] - 0.06586) < 0.0001 | ||
| assert abs(data[1]["user_misery"] - 0.05751) < 0.0001 | ||
| assert abs(data[0]["user_misery"] - 0.05751) < 0.0001 | ||
| assert abs(data[1]["user_misery"] - 0.06586) < 0.0001 | ||
|
|
||
| def test_user_misery_alias_field_with_transaction_threshold(self): | ||
| project = self.create_project() | ||
|
|
@@ -3166,14 +3173,14 @@ def test_deleted_issue_in_results(self): | |
| event2.group.delete() | ||
|
|
||
| features = {"organizations:discover-basic": True, "organizations:global-views": True} | ||
| query = {"field": ["issue", "count()"], "sort": "issue"} | ||
| query = {"field": ["issue", "count()"], "sort": "count()"} | ||
| response = self.do_request(query, features=features) | ||
|
|
||
| assert response.status_code == 200, response.content | ||
| data = response.data["data"] | ||
| assert len(data) == 2 | ||
| assert data[0]["issue"] == event1.group.qualified_short_id | ||
| assert data[1]["issue"] == "unknown" | ||
| assert data[0]["issue"] == "unknown" | ||
| assert data[1]["issue"] == event1.group.qualified_short_id | ||
|
|
||
| def test_last_seen_negative_duration(self): | ||
| project = self.create_project() | ||
|
|
@@ -4473,3 +4480,9 @@ def test_mobile_measurements(self): | |
| assert meta["p75_measurements_stall_percentage"] == "percentage" | ||
| assert meta["percentile_measurements_frames_slow_rate_0_5"] == "percentage" | ||
| assert meta["percentile_measurements_stall_percentage_0_5"] == "percentage" | ||
|
|
||
|
|
||
| class OrganizationEventsV2EndpointTestWithSnql(OrganizationEventsV2EndpointTest): | ||
| def setUp(self): | ||
| super().setUp() | ||
| self.features["organizations:discover-use-snql"] = True | ||
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.
Was this test never flakey somehow? But 👍 to making the result more deterministic.