From 265a7a5f6f450f97794a6b25731a634ae7448c41 Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Thu, 22 Jun 2023 10:00:58 -0700 Subject: [PATCH] feat(search-issues): Start writing message column in search issues (#4387) This adds the `message` column to search issues and starts writing to it. `message` is already being sent, but we missed including it a column initially. I will let this write for a week or two before switching over to use it. We don't need the full 90 days of data for this to be effective. --- .../configuration/issues/entities/search_issues.yaml | 1 + .../configuration/issues/storages/search_issues.yaml | 1 + snuba/datasets/processors/search_issues_processor.py | 2 ++ snuba/snuba_migrations/search_issues/__init__.py | 0 tests/datasets/test_search_issues_processor.py | 10 ++++++++++ tests/test_search_issues_api.py | 2 ++ 6 files changed, 16 insertions(+) create mode 100644 snuba/snuba_migrations/search_issues/__init__.py diff --git a/snuba/datasets/configuration/issues/entities/search_issues.yaml b/snuba/datasets/configuration/issues/entities/search_issues.yaml index 508030901f..3a81f8cfc6 100644 --- a/snuba/datasets/configuration/issues/entities/search_issues.yaml +++ b/snuba/datasets/configuration/issues/entities/search_issues.yaml @@ -9,6 +9,7 @@ schema: { name: group_id, type: UInt, args: { size: 64 } }, { name: search_title, type: String }, { name: resource_id, type: String }, + { name: message, type: String }, { name: subtitle, type: String }, { name: culprit, type: String }, { name: level, type: String, args: { schema_modifiers: [ low_cardinality ] } }, diff --git a/snuba/datasets/configuration/issues/storages/search_issues.yaml b/snuba/datasets/configuration/issues/storages/search_issues.yaml index 87f79ce9fc..e9e30c71d1 100644 --- a/snuba/datasets/configuration/issues/storages/search_issues.yaml +++ b/snuba/datasets/configuration/issues/storages/search_issues.yaml @@ -23,6 +23,7 @@ schema: { name: resource_id, type: String, args: { schema_modifiers: [ nullable ] } }, + { name: message, type: String }, { name: subtitle, type: String, args: { schema_modifiers: [ nullable ] } }, { name: culprit, type: String, args: { schema_modifiers: [ nullable ] } }, { name: level, type: String, args: { schema_modifiers: [ nullable ] } }, diff --git a/snuba/datasets/processors/search_issues_processor.py b/snuba/datasets/processors/search_issues_processor.py index 1de9291d33..c0c65b0f8d 100644 --- a/snuba/datasets/processors/search_issues_processor.py +++ b/snuba/datasets/processors/search_issues_processor.py @@ -92,6 +92,7 @@ class SearchIssueEvent(TypedDict, total=False): group_id: int platform: str primary_hash: str + message: str datetime: str data: IssueEventData @@ -276,6 +277,7 @@ def process_insert_v1( "receive_timestamp": receive_timestamp, "client_timestamp": client_timestamp, "platform": event["platform"], + "message": _unicodify(event["message"]), } # optional fields diff --git a/snuba/snuba_migrations/search_issues/__init__.py b/snuba/snuba_migrations/search_issues/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/datasets/test_search_issues_processor.py b/tests/datasets/test_search_issues_processor.py index bd9b635b16..e2a36ce4db 100644 --- a/tests/datasets/test_search_issues_processor.py +++ b/tests/datasets/test_search_issues_processor.py @@ -36,6 +36,7 @@ def message_base() -> SearchIssueEvent: "primary_hash": str(uuid.uuid4()), "datetime": datetime.utcnow().isoformat() + "Z", "platform": "other", + "message": "something", "data": { "received": datetime.now().timestamp(), }, @@ -70,6 +71,7 @@ class TestSearchIssuesMessageProcessor: "platform", "tags.key", "tags.value", + "message", } def process_message( @@ -439,6 +441,14 @@ def test_extract_replay_id(self, message_base): with pytest.raises(ValueError): self.process_message(message_base) + def test_extract_message(self, message_base): + message = "a message" + message_base["message"] = message + processed = self.process_message(message_base) + self.assert_required_columns(processed) + insert_row = processed.rows[0] + assert insert_row["message"] == message + def test_ensure_uuid(self): with pytest.raises(ValueError): ensure_uuid("not_a_uuid") diff --git a/tests/test_search_issues_api.py b/tests/test_search_issues_api.py index 425e7b2dc0..29704990c9 100644 --- a/tests/test_search_issues_api.py +++ b/tests/test_search_issues_api.py @@ -29,6 +29,7 @@ def base_insert_event( "primary_hash": str(uuid.uuid4()), "datetime": datetime.utcnow().isoformat() + "Z", "platform": "other", + "message": "message", "data": { "received": now.timestamp(), }, @@ -94,6 +95,7 @@ def test_simple_search_query(self) -> None: primary_hash=str(uuid.uuid4().hex), datetime=datetime.utcnow().isoformat() + "Z", platform="other", + message="message", data={"received": now.timestamp()}, occurrence_data=dict( id=str(uuid.uuid4().hex),