From 827731260d338759fa115c2a8d36beba23c3eb1b Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 22 Mar 2023 13:23:54 +0100 Subject: [PATCH 01/18] Make error.main_thread searchable on Discover and Issues page --- .../rules/conditions/event_attribute.py | 23 ++++++++---- src/sentry/snuba/events.py | 8 ++++ .../rules/conditions/test_event_attribute.py | 37 +++++++++++++++++++ 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/src/sentry/rules/conditions/event_attribute.py b/src/sentry/rules/conditions/event_attribute.py index 5588f563efb047..e2345bec8bc53b 100644 --- a/src/sentry/rules/conditions/event_attribute.py +++ b/src/sentry/rules/conditions/event_attribute.py @@ -18,6 +18,7 @@ "type": Columns.TYPE, "error.handled": Columns.ERROR_HANDLED, "error.unhandled": Columns.ERROR_HANDLED, + "error.main_thread": Columns.ERROR_MAIN_THREAD, "exception.type": Columns.ERROR_TYPE, "exception.value": Columns.ERROR_VALUE, "user.id": Columns.USER_ID, @@ -118,17 +119,23 @@ def _get_attribute_values(self, event: GroupEvent, attr: str) -> Sequence[str]: return [getattr(e, path[1]) for e in event.interfaces["exception"].values] elif path[0] == "error": - if path[1] not in ("handled", "unhandled"): + if path[1] not in ("handled", "unhandled", "main_thread"): return [] - # Flip "handled" to "unhandled" - negate = path[1] == "unhandled" + if path[1] in ("handled", "unhandled"): + # Flip "handled" to "unhandled" + negate = path[1] == "unhandled" - return [ - e.mechanism.handled != negate - for e in event.interfaces["exception"].values - if e.mechanism is not None and getattr(e.mechanism, "handled") is not None - ] + return [ + e.mechanism.handled != negate + for e in event.interfaces["exception"].values + if e.mechanism is not None and getattr(e.mechanism, "handled") is not None + ] + elif path[1] in ("main_thread"): + exception_main_thread = event.data["exception_main_thread"] + if exception_main_thread is None: + return [] + return [exception_main_thread] elif path[0] == "user": if path[1] in ("id", "ip_address", "email", "username"): diff --git a/src/sentry/snuba/events.py b/src/sentry/snuba/events.py index 1fdd56a1870e18..6050aec2f7e1d7 100644 --- a/src/sentry/snuba/events.py +++ b/src/sentry/snuba/events.py @@ -480,6 +480,14 @@ class Columns(Enum): discover_name="exception_stacks.mechanism_handled", alias="error.handled", ) + ERROR_MAIN_THREAD = Column( + group_name="events.exception_main_thread", + event_name="exception_main_thread", + transaction_name=None, + discover_name="exception_main_thread", + issue_platform_name="exception_main_thread", + alias="error.main_thread", + ) ERROR_RECEIVED = Column( group_name=None, event_name="received", diff --git a/tests/sentry/rules/conditions/test_event_attribute.py b/tests/sentry/rules/conditions/test_event_attribute.py index e0d6a431438638..53d5e8c6a92b3b 100644 --- a/tests/sentry/rules/conditions/test_event_attribute.py +++ b/tests/sentry/rules/conditions/test_event_attribute.py @@ -32,6 +32,7 @@ def get_event(self, **kwargs): } ] }, + "thread_id": 1, } ] }, @@ -57,6 +58,14 @@ def get_event(self, **kwargs): "crash_type": "crash", }, }, + "threads": { + "values": [ + { + "id": 1, + "main": True, + }, + ], + }, } data.update(kwargs) event = self.store_event(data, project_id=self.project.id) @@ -370,6 +379,34 @@ def test_error_unhandled(self): ) self.assertDoesNotPass(rule, event) + def test_error_main_thread(self): + event = self.get_event() + rule = self.get_rule( + data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "True"} + ) + self.assertPasses(rule, event) + + rule = self.get_rule( + data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "False"} + ) + self.assertDoesNotPass(rule, event) + + def test_error_main_thread_no_threads(self): + event = self.get_event( + threads={ + "values": [], + } + ) + rule = self.get_rule( + data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "True"} + ) + self.assertDoesNotPass(rule, event) + + rule = self.get_rule( + data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "False"} + ) + self.assertDoesNotPass(rule, event) + def test_exception_value(self): event = self.get_event() rule = self.get_rule( From 5b96ba2afabc56dacda794dd9c4e5a06a2e5e7ed Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 29 Mar 2023 10:47:16 +0200 Subject: [PATCH 02/18] set main_thread as boolean --- src/sentry/api/event_search.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sentry/api/event_search.py b/src/sentry/api/event_search.py index fcc9a1e4709291..1deb66ad9c5d84 100644 --- a/src/sentry/api/event_search.py +++ b/src/sentry/api/event_search.py @@ -1129,6 +1129,7 @@ def generic_visit(self, node, children): boolean_keys={ "error.handled", "error.unhandled", + "error.main_thread", "stack.in_app", TEAM_KEY_TRANSACTION_ALIAS, }, From b9e0bb9077963a869b6ac9eafe5749a9856c190f Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 30 Mar 2023 13:01:35 +0200 Subject: [PATCH 03/18] review --- src/sentry/issues/search.py | 2 +- src/sentry/snuba/events.py | 2 +- tests/snuba/search/test_backend.py | 26 +++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/sentry/issues/search.py b/src/sentry/issues/search.py index c5deaaf0d398cf..8e306fc58030e0 100644 --- a/src/sentry/issues/search.py +++ b/src/sentry/issues/search.py @@ -256,7 +256,7 @@ def _update_profiling_search_filters( for sf in search_filters: # XXX: we replace queries on these keys to something that should return nothing since # profiling issues doesn't support stacktraces - if sf.key.name in ("error.unhandled", "error.handled"): + if sf.key.name in ("error.unhandled", "error.handled", "error.main_thread"): raise UnsupportedSearchQuery( f"{sf.key.name} filter isn't supported for {GroupCategory.PROFILE.name}" ) diff --git a/src/sentry/snuba/events.py b/src/sentry/snuba/events.py index 6050aec2f7e1d7..a709dbc3f7e919 100644 --- a/src/sentry/snuba/events.py +++ b/src/sentry/snuba/events.py @@ -485,7 +485,7 @@ class Columns(Enum): event_name="exception_main_thread", transaction_name=None, discover_name="exception_main_thread", - issue_platform_name="exception_main_thread", + issue_platform_name=None, alias="error.main_thread", ) ERROR_RECEIVED = Column( diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index da800515206e8c..009798fbb539d6 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -2468,7 +2468,31 @@ def test_rejected_filters(self): count_hits=True, ) - assert list(results) == list(results2) == list(result3) == list(results4) == [] + results5 = self.make_query( + projects=[self.project], + search_filter_query="error.main_thread:0", + sort_by="date", + limit=1, + count_hits=True, + ) + + results6 = self.make_query( + projects=[self.project], + search_filter_query="error.main_thread:1", + sort_by="date", + limit=1, + count_hits=True, + ) + + assert ( + list(results) + == list(results2) + == list(result3) + == list(results4) + == list(results5) + == list(results6) + == [] + ) class CdcEventsSnubaSearchTest(SharedSnubaTest): From b85124f1e095aee65669d91fbc1dcd82d007e561 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 30 Mar 2023 13:49:09 +0200 Subject: [PATCH 04/18] fix test --- tests/snuba/search/test_backend.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 009798fbb539d6..4f9e8e4d085758 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -2470,7 +2470,7 @@ def test_rejected_filters(self): results5 = self.make_query( projects=[self.project], - search_filter_query="error.main_thread:0", + search_filter_query="issue.category:profile error.main_thread:0", sort_by="date", limit=1, count_hits=True, @@ -2478,7 +2478,7 @@ def test_rejected_filters(self): results6 = self.make_query( projects=[self.project], - search_filter_query="error.main_thread:1", + search_filter_query="issue.category:profile error.main_thread:1", sort_by="date", limit=1, count_hits=True, From ed18c3106a78bffb0caa888684786a63a7dc3d11 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 30 Mar 2023 15:48:25 +0200 Subject: [PATCH 05/18] add test --- src/sentry/data/samples/android-ndk.json | 9 +++++++ .../api/endpoints/test_organization_events.py | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/sentry/data/samples/android-ndk.json b/src/sentry/data/samples/android-ndk.json index ba1596503fc9ba..3b78c09a362c4d 100644 --- a/src/sentry/data/samples/android-ndk.json +++ b/src/sentry/data/samples/android-ndk.json @@ -6,6 +6,7 @@ { "type": "SIGSEGV", "value": "Segfault", + "thread_id": 1, "mechanism": { "type": "signalhandler", "synthetic": true, @@ -132,6 +133,14 @@ } ] }, + "threads": { + "values": [ + { + "id": 1, + "main": true + } + ] + }, "platform": "native", "debug_meta": { "images": [ diff --git a/tests/snuba/api/endpoints/test_organization_events.py b/tests/snuba/api/endpoints/test_organization_events.py index 6bab12ca2dc62a..5b3f9ca98fdbbd 100644 --- a/tests/snuba/api/endpoints/test_organization_events.py +++ b/tests/snuba/api/endpoints/test_organization_events.py @@ -1165,6 +1165,31 @@ def test_groupby_error_handled_and_unhandled(self): assert 1 == response.data["data"][1]["error.unhandled"] assert 1 == response.data["data"][1]["count()"] + def test_error_main_thread_condition(self): + prototype = self.load_data(platform="android-ndk") + + prototype["event_id"] = "a" * 32 + prototype["timestamp"] = self.ten_mins_ago_iso + self.store_event(data=prototype, project_id=self.project.id) + + with self.feature("organizations:discover-basic"): + query = { + "field": ["id"], + "query": "error.main_thread:true", + } + response = self.do_request(query) + assert response.status_code == 200, response.data + assert 1 == len(response.data["data"]) + + with self.feature("organizations:discover-basic"): + query = { + "field": ["id"], + "query": "error.main_thread:false", + } + response = self.do_request(query) + assert response.status_code == 200, response.data + assert 0 == len(response.data["data"]) + def test_implicit_groupby(self): self.store_event( data={ From f0b2b1ce25df405d28dec424c0fe5ee2b92bac69 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 30 Mar 2023 16:08:09 +0200 Subject: [PATCH 06/18] fix test --- tests/snuba/api/endpoints/test_organization_events.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/snuba/api/endpoints/test_organization_events.py b/tests/snuba/api/endpoints/test_organization_events.py index 5b3f9ca98fdbbd..80a41fab52a715 100644 --- a/tests/snuba/api/endpoints/test_organization_events.py +++ b/tests/snuba/api/endpoints/test_organization_events.py @@ -1168,14 +1168,14 @@ def test_groupby_error_handled_and_unhandled(self): def test_error_main_thread_condition(self): prototype = self.load_data(platform="android-ndk") - prototype["event_id"] = "a" * 32 prototype["timestamp"] = self.ten_mins_ago_iso self.store_event(data=prototype, project_id=self.project.id) with self.feature("organizations:discover-basic"): query = { - "field": ["id"], + "field": ["id", "project.id"], "query": "error.main_thread:true", + "project": [self.project.id], } response = self.do_request(query) assert response.status_code == 200, response.data From 7da40bc3d458e23a88e55a7c4923324000e44ab6 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 30 Mar 2023 16:09:23 +0200 Subject: [PATCH 07/18] fix test --- tests/snuba/api/endpoints/test_organization_events.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/snuba/api/endpoints/test_organization_events.py b/tests/snuba/api/endpoints/test_organization_events.py index 80a41fab52a715..3dc40f36613bf7 100644 --- a/tests/snuba/api/endpoints/test_organization_events.py +++ b/tests/snuba/api/endpoints/test_organization_events.py @@ -1183,8 +1183,9 @@ def test_error_main_thread_condition(self): with self.feature("organizations:discover-basic"): query = { - "field": ["id"], - "query": "error.main_thread:false", + "field": ["id", "project.id"], + "query": "error.main_thread:true", + "project": [self.project.id], } response = self.do_request(query) assert response.status_code == 200, response.data From 5a9b83f16c67c104ed513f350b8f5704714302ef Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 30 Mar 2023 16:11:03 +0200 Subject: [PATCH 08/18] fix test --- tests/snuba/api/endpoints/test_organization_events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/snuba/api/endpoints/test_organization_events.py b/tests/snuba/api/endpoints/test_organization_events.py index 3dc40f36613bf7..64ae80ec2761ed 100644 --- a/tests/snuba/api/endpoints/test_organization_events.py +++ b/tests/snuba/api/endpoints/test_organization_events.py @@ -1184,7 +1184,7 @@ def test_error_main_thread_condition(self): with self.feature("organizations:discover-basic"): query = { "field": ["id", "project.id"], - "query": "error.main_thread:true", + "query": "error.main_thread:false", "project": [self.project.id], } response = self.do_request(query) From 2eb47367fdf666046873141978655f738c2245d0 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Fri, 31 Mar 2023 09:22:21 +0200 Subject: [PATCH 09/18] fix --- .../rules/conditions/event_attribute.py | 24 +++++++--------- .../rules/conditions/test_event_attribute.py | 28 ------------------- 2 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/sentry/rules/conditions/event_attribute.py b/src/sentry/rules/conditions/event_attribute.py index e2345bec8bc53b..730f10f5f9e6d4 100644 --- a/src/sentry/rules/conditions/event_attribute.py +++ b/src/sentry/rules/conditions/event_attribute.py @@ -119,23 +119,19 @@ def _get_attribute_values(self, event: GroupEvent, attr: str) -> Sequence[str]: return [getattr(e, path[1]) for e in event.interfaces["exception"].values] elif path[0] == "error": - if path[1] not in ("handled", "unhandled", "main_thread"): + # TODO: add support for error.main_thread + + if path[1] not in ("handled", "unhandled"): return [] - if path[1] in ("handled", "unhandled"): - # Flip "handled" to "unhandled" - negate = path[1] == "unhandled" + # Flip "handled" to "unhandled" + negate = path[1] == "unhandled" - return [ - e.mechanism.handled != negate - for e in event.interfaces["exception"].values - if e.mechanism is not None and getattr(e.mechanism, "handled") is not None - ] - elif path[1] in ("main_thread"): - exception_main_thread = event.data["exception_main_thread"] - if exception_main_thread is None: - return [] - return [exception_main_thread] + return [ + e.mechanism.handled != negate + for e in event.interfaces["exception"].values + if e.mechanism is not None and getattr(e.mechanism, "handled") is not None + ] elif path[0] == "user": if path[1] in ("id", "ip_address", "email", "username"): diff --git a/tests/sentry/rules/conditions/test_event_attribute.py b/tests/sentry/rules/conditions/test_event_attribute.py index 53d5e8c6a92b3b..ebd595216b43c6 100644 --- a/tests/sentry/rules/conditions/test_event_attribute.py +++ b/tests/sentry/rules/conditions/test_event_attribute.py @@ -379,34 +379,6 @@ def test_error_unhandled(self): ) self.assertDoesNotPass(rule, event) - def test_error_main_thread(self): - event = self.get_event() - rule = self.get_rule( - data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "True"} - ) - self.assertPasses(rule, event) - - rule = self.get_rule( - data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "False"} - ) - self.assertDoesNotPass(rule, event) - - def test_error_main_thread_no_threads(self): - event = self.get_event( - threads={ - "values": [], - } - ) - rule = self.get_rule( - data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "True"} - ) - self.assertDoesNotPass(rule, event) - - rule = self.get_rule( - data={"match": MatchType.EQUAL, "attribute": "error.main_thread", "value": "False"} - ) - self.assertDoesNotPass(rule, event) - def test_exception_value(self): event = self.get_event() rule = self.get_rule( From b350de461a317f2789491fcaadfa571f22964e8f Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 6 Apr 2023 11:02:59 +0200 Subject: [PATCH 10/18] add test to events snuba search test --- tests/snuba/search/test_backend.py | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 4f9e8e4d085758..7c524f82716acc 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -1973,6 +1973,44 @@ def test_message_negation(self): assert list(results) == list(results2) + def test_error_main_thread_true(self): + self.store_event( + data={ + "fingerprint": ["put-me-in-group1"], + "event_id": "2" * 32, + "message": "something", + "timestamp": iso_format(self.base_datetime), + "exception": { + "values": [ + { + "type": "SyntaxError", + "value": "hello world", + "thread_id": 1, + }, + ], + }, + "threads": { + "values": [ + { + "id": 1, + "main": True, + }, + ], + }, + }, + project_id=self.project.id, + ) + + results = self.make_query( + projects=[self.project], + search_filter_query="error.handled:1", + sort_by="date", + limit=1, + count_hits=True, + ) + + assert results.hits == 1 + class EventsTransactionsSnubaSearchTest(SharedSnubaTest): @property From 84f068b8072a10f616c02a0d35a633acd99742a2 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 6 Apr 2023 11:42:00 +0200 Subject: [PATCH 11/18] fix --- tests/snuba/search/test_backend.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 7c524f82716acc..3e3d1a0507c760 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -2005,11 +2005,9 @@ def test_error_main_thread_true(self): projects=[self.project], search_filter_query="error.handled:1", sort_by="date", - limit=1, - count_hits=True, ) - assert results.hits == 1 + assert len(results) == 1 class EventsTransactionsSnubaSearchTest(SharedSnubaTest): From e9c36a2dab1cb924a74cd7f2c50be77e3098e31e Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 6 Apr 2023 11:56:59 +0200 Subject: [PATCH 12/18] remove fingerprint --- tests/snuba/search/test_backend.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 3e3d1a0507c760..4dbf2ba8022874 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -1976,7 +1976,6 @@ def test_message_negation(self): def test_error_main_thread_true(self): self.store_event( data={ - "fingerprint": ["put-me-in-group1"], "event_id": "2" * 32, "message": "something", "timestamp": iso_format(self.base_datetime), From adaf91afb2bee9d69b5b171a8e5281f261a143d7 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 6 Apr 2023 14:12:12 +0200 Subject: [PATCH 13/18] test --- tests/snuba/search/test_backend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 4dbf2ba8022874..58f1ddd4487ce8 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -1974,7 +1974,7 @@ def test_message_negation(self): assert list(results) == list(results2) def test_error_main_thread_true(self): - self.store_event( + event = self.store_event( data={ "event_id": "2" * 32, "message": "something", @@ -2006,7 +2006,8 @@ def test_error_main_thread_true(self): sort_by="date", ) - assert len(results) == 1 + # assert list(event) == list(results) + assert set(results) == {event.group} class EventsTransactionsSnubaSearchTest(SharedSnubaTest): From 0a33954ed9398c8851d79cdc58286390accfd87b Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 11 Apr 2023 09:40:57 +0200 Subject: [PATCH 14/18] fix test --- tests/snuba/search/test_backend.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 24889c4783412b..5e990408b67645 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -1975,6 +1975,10 @@ def test_message_negation(self): assert list(results) == list(results2) def test_error_main_thread_true(self): + myProject = self.create_project( + name="Foo", slug="foo", teams=[self.team], fire_project_created=True + ) + event = self.store_event( data={ "event_id": "2" * 32, @@ -1998,17 +2002,18 @@ def test_error_main_thread_true(self): ], }, }, - project_id=self.project.id, + project_id=myProject.id, ) + myGroup = event.groups[0] + results = self.make_query( - projects=[self.project], + projects=[myProject], search_filter_query="error.handled:1", sort_by="date", ) - # assert list(event) == list(results) - assert set(results) == {event.group} + assert list(myGroup) == list(results) class EventsTransactionsSnubaSearchTest(SharedSnubaTest): From 7340a05b44918ce594cd52e639c91eb60fe182f3 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 11 Apr 2023 10:14:06 +0200 Subject: [PATCH 15/18] fix --- tests/snuba/search/test_backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 5e990408b67645..b02072c46e1c92 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -2013,7 +2013,7 @@ def test_error_main_thread_true(self): sort_by="date", ) - assert list(myGroup) == list(results) + assert list(results) == [myGroup] class EventsTransactionsSnubaSearchTest(SharedSnubaTest): From abe886a6c7ae3db490339ac9f141010163f85ec8 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 11 Apr 2023 10:56:41 +0200 Subject: [PATCH 16/18] add more tests --- tests/snuba/search/test_backend.py | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index b02072c46e1c92..f0e39c4d10207f 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -2015,6 +2015,85 @@ def test_error_main_thread_true(self): assert list(results) == [myGroup] + def test_error_main_thread_false(self): + myProject = self.create_project( + name="Foo", slug="foo", teams=[self.team], fire_project_created=True + ) + + event = self.store_event( + data={ + "event_id": "2" * 32, + "message": "something", + "timestamp": iso_format(self.base_datetime), + "exception": { + "values": [ + { + "type": "SyntaxError", + "value": "hello world", + "thread_id": 1, + }, + ], + }, + "threads": { + "values": [ + { + "id": 1, + "main": False, + }, + ], + }, + }, + project_id=myProject.id, + ) + + myGroup = event.groups[0] + + results = self.make_query( + projects=[myProject], + search_filter_query="error.handled:0", + sort_by="date", + ) + + assert list(results) == [myGroup] + + def test_error_main_thread_no_results(self): + myProject = self.create_project( + name="Foo", slug="foo", teams=[self.team], fire_project_created=True + ) + + self.store_event( + data={ + "event_id": "2" * 32, + "message": "something", + "timestamp": iso_format(self.base_datetime), + "exception": { + "values": [ + { + "type": "SyntaxError", + "value": "hello world", + "thread_id": 1, + }, + ], + }, + "threads": { + "values": [ + { + "id": 1, + }, + ], + }, + }, + project_id=myProject.id, + ) + + results = self.make_query( + projects=[myProject], + search_filter_query="error.handled:0", + sort_by="date", + ) + + assert len(results) == 0 + class EventsTransactionsSnubaSearchTest(SharedSnubaTest): @property From b96c6398c3c55301f3695e6958adf6f512e5ced9 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 11 Apr 2023 11:24:23 +0200 Subject: [PATCH 17/18] fix --- tests/snuba/search/test_backend.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index f0e39c4d10207f..609419db2ef17b 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -1981,7 +1981,7 @@ def test_error_main_thread_true(self): event = self.store_event( data={ - "event_id": "2" * 32, + "event_id": "1" * 32, "message": "something", "timestamp": iso_format(self.base_datetime), "exception": { @@ -2017,7 +2017,7 @@ def test_error_main_thread_true(self): def test_error_main_thread_false(self): myProject = self.create_project( - name="Foo", slug="foo", teams=[self.team], fire_project_created=True + name="Foo2", slug="foo2", teams=[self.team], fire_project_created=True ) event = self.store_event( @@ -2058,12 +2058,12 @@ def test_error_main_thread_false(self): def test_error_main_thread_no_results(self): myProject = self.create_project( - name="Foo", slug="foo", teams=[self.team], fire_project_created=True + name="Foo3", slug="foo3", teams=[self.team], fire_project_created=True ) self.store_event( data={ - "event_id": "2" * 32, + "event_id": "3" * 32, "message": "something", "timestamp": iso_format(self.base_datetime), "exception": { From c45bfead5766c7f8becb14a2032375c51580bb3e Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 11 Apr 2023 11:47:14 +0200 Subject: [PATCH 18/18] fix query search --- tests/snuba/search/test_backend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/snuba/search/test_backend.py b/tests/snuba/search/test_backend.py index 609419db2ef17b..d1cf76461e4e94 100644 --- a/tests/snuba/search/test_backend.py +++ b/tests/snuba/search/test_backend.py @@ -2009,7 +2009,7 @@ def test_error_main_thread_true(self): results = self.make_query( projects=[myProject], - search_filter_query="error.handled:1", + search_filter_query="error.main_thread:1", sort_by="date", ) @@ -2050,7 +2050,7 @@ def test_error_main_thread_false(self): results = self.make_query( projects=[myProject], - search_filter_query="error.handled:0", + search_filter_query="error.main_thread:0", sort_by="date", ) @@ -2088,7 +2088,7 @@ def test_error_main_thread_no_results(self): results = self.make_query( projects=[myProject], - search_filter_query="error.handled:0", + search_filter_query="error.main_thread:1", sort_by="date", )