From 3b2f77da6b39c23889401c3b56429ab8023dd8f1 Mon Sep 17 00:00:00 2001 From: Oliver Browne Date: Mon, 18 Nov 2024 13:58:59 +0200 Subject: [PATCH] fix(err): add issue name and description (#26200) --- ...errortrackingissue_description_and_more.py | 22 ++ posthog/migrations/max_migration.txt | 2 +- .../models/error_tracking/error_tracking.py | 2 + ...75c285bc510766c175b1b8c4e4002e04ff503.json | 21 +- ...f1997fc9cf1fb3436d742e9374ad4f2d55614.json | 27 +- ...f68cd3acdf4dabc1eff87ae7bce49cee9328a.json | 79 +++--- ...c165376f43116b85921c62b36b1b8e85562b0.json | 248 +++++++++--------- ...491f908b5047e86b13fbff22cf8f58e85cc81.json | 47 ++++ ...9c4bbd0c3a17b7ea65767cf5e7512e5a6ea89.json | 35 +-- ...3d0e39f01b19b243d724b09f3ce6617d03dc7.json | 21 +- ...8686c4393f6420e61b6b141143974ff362213.json | 90 ++++--- ...873bf6d1d43884cd628df5b36978dd761b025.json | 35 +-- ...ab521aa6f393027c399a0c40139f5f8a0a45e.json | 22 +- ...13132c3e7bf297834cd42228b35bf3e424dd7.json | 18 -- ...8dc46c18f4950a7951d2c412dcba4d13fb56b.json | 101 +++---- ...554065b71152389f98d35532c6b332d5a4c9d.json | 20 +- ...4711bdfb8cf78e362ccda8bc14e92324d51f8.json | 34 +-- ...d687eb545ee9d4ccbb8b69c958a357d49f687.json | 23 +- ...b59cc00f3125413f4032ac3647a6b5ee1a632.json | 35 +-- ...ec3544acd0228776b8535f22438db59002e1f.json | 28 -- ...074995829d1372fe8ec1fd683f9524bcebb8b.json | 43 +-- ...a76bd8a7d96d73983a0c408f32f17da5f483b.json | 22 +- ...52ea79485e403b9e17b6c37259ea0612065ee.json | 35 +-- ...52345454cd3323568c4bef5b8480380287068.json | 248 +++++++++--------- ...93c27fdf4d88145cd7eaf4bbd39e49a7452f6.json | 26 ++ ...856c4cbd8beb519df8212212017dda9d06c51.json | 76 +++--- ...29c948a291ea8218bbbb4e25cd1ad36dbe9f4.json | 26 +- ...af30c682288988fc6f102e8a063be97c3e51c.json | 60 +++-- ...f6c959ba804dab9c1e5ba39979d19782582ea.json | 81 +++--- ...21c0eae35356f7b92e969a12a839b41cd360a.json | 25 +- rust/cymbal/src/frames/resolver.rs | 6 +- rust/cymbal/src/issue_resolution.rs | 48 +++- rust/cymbal/src/lib.rs | 46 +--- rust/cymbal/src/types/mod.rs | 68 +++-- rust/cymbal/tests/resolve.rs | 6 +- rust/cymbal/tests/types.rs | 4 +- 36 files changed, 978 insertions(+), 752 deletions(-) create mode 100644 posthog/migrations/0519_errortrackingissue_description_and_more.py create mode 100644 rust/.sqlx/query-2a1514685491269ca61a0a898d7491f908b5047e86b13fbff22cf8f58e85cc81.json delete mode 100644 rust/.sqlx/query-44eb698252059821770eaaf5b8213132c3e7bf297834cd42228b35bf3e424dd7.json delete mode 100644 rust/.sqlx/query-ad528f712bdaf75a82293018e3dec3544acd0228776b8535f22438db59002e1f.json create mode 100644 rust/.sqlx/query-e0c6790eccd2e7505d86ed570f093c27fdf4d88145cd7eaf4bbd39e49a7452f6.json diff --git a/posthog/migrations/0519_errortrackingissue_description_and_more.py b/posthog/migrations/0519_errortrackingissue_description_and_more.py new file mode 100644 index 0000000000000..f3faae82726e0 --- /dev/null +++ b/posthog/migrations/0519_errortrackingissue_description_and_more.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.15 on 2024-11-14 17:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("posthog", "0518_survey_internal_response_sampling_flag"), + ] + + operations = [ + migrations.AddField( + model_name="errortrackingissue", + name="description", + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name="errortrackingissue", + name="name", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt index 54603fe73b47f..6a1c8da5c16d3 100644 --- a/posthog/migrations/max_migration.txt +++ b/posthog/migrations/max_migration.txt @@ -1 +1 @@ -0518_survey_internal_response_sampling_flag \ No newline at end of file +0519_errortrackingissue_description_and_more diff --git a/posthog/models/error_tracking/error_tracking.py b/posthog/models/error_tracking/error_tracking.py index 982f21e4fa342..7e42f55cf9f77 100644 --- a/posthog/models/error_tracking/error_tracking.py +++ b/posthog/models/error_tracking/error_tracking.py @@ -17,6 +17,8 @@ class Status(models.TextChoices): team = models.ForeignKey(Team, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) status = models.TextField(choices=Status.choices, default=Status.ACTIVE, null=False) + name = models.TextField(null=True, blank=True) + description = models.TextField(null=True, blank=True) class ErrorTrackingIssueAssignment(UUIDModel): diff --git a/rust/.sqlx/query-075421be22b51c50eb74ac1156175c285bc510766c175b1b8c4e4002e04ff503.json b/rust/.sqlx/query-075421be22b51c50eb74ac1156175c285bc510766c175b1b8c4e4002e04ff503.json index a2cb4e3a0a883..35683fb0fb925 100644 --- a/rust/.sqlx/query-075421be22b51c50eb74ac1156175c285bc510766c175b1b8c4e4002e04ff503.json +++ b/rust/.sqlx/query-075421be22b51c50eb74ac1156175c285bc510766c175b1b8c4e4002e04ff503.json @@ -1,12 +1,15 @@ { - "db_name": "PostgreSQL", - "query": "UPDATE cyclotron_jobs SET last_heartbeat = NOW() WHERE id = $1 AND lock_id = $2", - "describe": { - "columns": [], - "parameters": { - "Left": ["Uuid", "Uuid"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "UPDATE cyclotron_jobs SET last_heartbeat = NOW() WHERE id = $1 AND lock_id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] }, - "hash": "075421be22b51c50eb74ac1156175c285bc510766c175b1b8c4e4002e04ff503" + "nullable": [] + }, + "hash": "075421be22b51c50eb74ac1156175c285bc510766c175b1b8c4e4002e04ff503" } diff --git a/rust/.sqlx/query-085d682315a548d578f63bb48d2f1997fc9cf1fb3436d742e9374ad4f2d55614.json b/rust/.sqlx/query-085d682315a548d578f63bb48d2f1997fc9cf1fb3436d742e9374ad4f2d55614.json index 972b51fccc511..9329bd2f2da48 100644 --- a/rust/.sqlx/query-085d682315a548d578f63bb48d2f1997fc9cf1fb3436d742e9374ad4f2d55614.json +++ b/rust/.sqlx/query-085d682315a548d578f63bb48d2f1997fc9cf1fb3436d742e9374ad4f2d55614.json @@ -1,12 +1,21 @@ { - "db_name": "PostgreSQL", - "query": "\n INSERT INTO posthog_errortrackingstackframe (raw_id, team_id, created_at, symbol_set_id, contents, resolved, id, context)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n ON CONFLICT (raw_id, team_id) DO UPDATE SET\n created_at = $3,\n symbol_set_id = $4,\n contents = $5,\n resolved = $6,\n context = $8\n ", - "describe": { - "columns": [], - "parameters": { - "Left": ["Text", "Int4", "Timestamptz", "Uuid", "Jsonb", "Bool", "Uuid", "Text"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "\n INSERT INTO posthog_errortrackingstackframe (raw_id, team_id, created_at, symbol_set_id, contents, resolved, id, context)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n ON CONFLICT (raw_id, team_id) DO UPDATE SET\n created_at = $3,\n symbol_set_id = $4,\n contents = $5,\n resolved = $6,\n context = $8\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int4", + "Timestamptz", + "Uuid", + "Jsonb", + "Bool", + "Uuid", + "Text" + ] }, - "hash": "085d682315a548d578f63bb48d2f1997fc9cf1fb3436d742e9374ad4f2d55614" + "nullable": [] + }, + "hash": "085d682315a548d578f63bb48d2f1997fc9cf1fb3436d742e9374ad4f2d55614" } diff --git a/rust/.sqlx/query-14332a535d61ab0144d1f4dbb1cf68cd3acdf4dabc1eff87ae7bce49cee9328a.json b/rust/.sqlx/query-14332a535d61ab0144d1f4dbb1cf68cd3acdf4dabc1eff87ae7bce49cee9328a.json index b489060b99660..c1b847f882401 100644 --- a/rust/.sqlx/query-14332a535d61ab0144d1f4dbb1cf68cd3acdf4dabc1eff87ae7bce49cee9328a.json +++ b/rust/.sqlx/query-14332a535d61ab0144d1f4dbb1cf68cd3acdf4dabc1eff87ae7bce49cee9328a.json @@ -1,38 +1,47 @@ { - "db_name": "PostgreSQL", - "query": "\n SELECT id, team_id, issue_id, fingerprint, version FROM posthog_errortrackingissuefingerprintv2\n WHERE team_id = $1 AND fingerprint = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "team_id", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "issue_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "fingerprint", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "version", - "type_info": "Int8" - } - ], - "parameters": { - "Left": ["Int4", "Text"] - }, - "nullable": [false, false, false, false, false] + "db_name": "PostgreSQL", + "query": "\n SELECT id, team_id, issue_id, fingerprint, version FROM posthog_errortrackingissuefingerprintv2\n WHERE team_id = $1 AND fingerprint = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "team_id", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "issue_id", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "fingerprint", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "version", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text" + ] }, - "hash": "14332a535d61ab0144d1f4dbb1cf68cd3acdf4dabc1eff87ae7bce49cee9328a" + "nullable": [ + false, + false, + false, + false, + false + ] + }, + "hash": "14332a535d61ab0144d1f4dbb1cf68cd3acdf4dabc1eff87ae7bce49cee9328a" } diff --git a/rust/.sqlx/query-229c28c25aec24180c29e6ed636c165376f43116b85921c62b36b1b8e85562b0.json b/rust/.sqlx/query-229c28c25aec24180c29e6ed636c165376f43116b85921c62b36b1b8e85562b0.json index ffda6f4b70b26..04f6c0838ae19 100644 --- a/rust/.sqlx/query-229c28c25aec24180c29e6ed636c165376f43116b85921c62b36b1b8e85562b0.json +++ b/rust/.sqlx/query-229c28c25aec24180c29e6ed636c165376f43116b85921c62b36b1b8e85562b0.json @@ -1,123 +1,133 @@ { - "db_name": "PostgreSQL", - "query": "\nWITH available AS (\n SELECT\n id,\n state\n FROM cyclotron_jobs\n WHERE\n state = 'available'::JobState\n AND queue_name = $1\n AND scheduled <= NOW()\n ORDER BY\n priority ASC,\n scheduled ASC\n LIMIT $2\n FOR UPDATE SKIP LOCKED\n)\nUPDATE cyclotron_jobs\nSET\n state = 'running'::JobState,\n lock_id = $3,\n last_heartbeat = NOW(),\n last_transition = NOW(),\n transition_count = transition_count + 1\nFROM available\nWHERE\n cyclotron_jobs.id = available.id\nRETURNING\n cyclotron_jobs.id,\n team_id,\n available.state as \"state: JobState\",\n queue_name,\n priority,\n function_id,\n created,\n last_transition,\n scheduled,\n transition_count,\n NULL::bytea as vm_state,\n metadata,\n parameters,\n blob,\n lock_id,\n last_heartbeat,\n janitor_touch_count\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "team_id", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "state: JobState", - "type_info": { - "Custom": { - "name": "jobstate", - "kind": { - "Enum": ["available", "completed", "failed", "running", "paused"] - } - } - } - }, - { - "ordinal": 3, - "name": "queue_name", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "priority", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "function_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "created", - "type_info": "Timestamptz" - }, - { - "ordinal": 7, - "name": "last_transition", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "scheduled", - "type_info": "Timestamptz" - }, - { - "ordinal": 9, - "name": "transition_count", - "type_info": "Int2" - }, - { - "ordinal": 10, - "name": "vm_state", - "type_info": "Bytea" - }, - { - "ordinal": 11, - "name": "metadata", - "type_info": "Bytea" - }, - { - "ordinal": 12, - "name": "parameters", - "type_info": "Bytea" - }, - { - "ordinal": 13, - "name": "blob", - "type_info": "Bytea" - }, - { - "ordinal": 14, - "name": "lock_id", - "type_info": "Uuid" - }, - { - "ordinal": 15, - "name": "last_heartbeat", - "type_info": "Timestamptz" - }, - { - "ordinal": 16, - "name": "janitor_touch_count", - "type_info": "Int2" + "db_name": "PostgreSQL", + "query": "\nWITH available AS (\n SELECT\n id,\n state\n FROM cyclotron_jobs\n WHERE\n state = 'available'::JobState\n AND queue_name = $1\n AND scheduled <= NOW()\n ORDER BY\n priority ASC,\n scheduled ASC\n LIMIT $2\n FOR UPDATE SKIP LOCKED\n)\nUPDATE cyclotron_jobs\nSET\n state = 'running'::JobState,\n lock_id = $3,\n last_heartbeat = NOW(),\n last_transition = NOW(),\n transition_count = transition_count + 1\nFROM available\nWHERE\n cyclotron_jobs.id = available.id\nRETURNING\n cyclotron_jobs.id,\n team_id,\n available.state as \"state: JobState\",\n queue_name,\n priority,\n function_id,\n created,\n last_transition,\n scheduled,\n transition_count,\n NULL::bytea as vm_state,\n metadata,\n parameters,\n blob,\n lock_id,\n last_heartbeat,\n janitor_touch_count\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "team_id", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "state: JobState", + "type_info": { + "Custom": { + "name": "jobstate", + "kind": { + "Enum": [ + "available", + "completed", + "failed", + "running", + "paused" + ] } - ], - "parameters": { - "Left": ["Text", "Int8", "Uuid"] - }, - "nullable": [ - false, - false, - false, - false, - false, - true, - false, - false, - false, - false, - null, - true, - true, - true, - true, - true, - false - ] + } + } + }, + { + "ordinal": 3, + "name": "queue_name", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "priority", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "function_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "created", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "last_transition", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "scheduled", + "type_info": "Timestamptz" + }, + { + "ordinal": 9, + "name": "transition_count", + "type_info": "Int2" + }, + { + "ordinal": 10, + "name": "vm_state", + "type_info": "Bytea" + }, + { + "ordinal": 11, + "name": "metadata", + "type_info": "Bytea" + }, + { + "ordinal": 12, + "name": "parameters", + "type_info": "Bytea" + }, + { + "ordinal": 13, + "name": "blob", + "type_info": "Bytea" + }, + { + "ordinal": 14, + "name": "lock_id", + "type_info": "Uuid" + }, + { + "ordinal": 15, + "name": "last_heartbeat", + "type_info": "Timestamptz" + }, + { + "ordinal": 16, + "name": "janitor_touch_count", + "type_info": "Int2" + } + ], + "parameters": { + "Left": [ + "Text", + "Int8", + "Uuid" + ] }, - "hash": "229c28c25aec24180c29e6ed636c165376f43116b85921c62b36b1b8e85562b0" + "nullable": [ + false, + false, + false, + false, + false, + true, + false, + false, + false, + false, + null, + true, + true, + true, + true, + true, + false + ] + }, + "hash": "229c28c25aec24180c29e6ed636c165376f43116b85921c62b36b1b8e85562b0" } diff --git a/rust/.sqlx/query-2a1514685491269ca61a0a898d7491f908b5047e86b13fbff22cf8f58e85cc81.json b/rust/.sqlx/query-2a1514685491269ca61a0a898d7491f908b5047e86b13fbff22cf8f58e85cc81.json new file mode 100644 index 0000000000000..970ef47266837 --- /dev/null +++ b/rust/.sqlx/query-2a1514685491269ca61a0a898d7491f908b5047e86b13fbff22cf8f58e85cc81.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, team_id, status, name, description FROM posthog_errortrackingissue\n WHERE team_id = $1 AND id = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "team_id", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "status", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "name", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "description", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Int4", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + true, + true + ] + }, + "hash": "2a1514685491269ca61a0a898d7491f908b5047e86b13fbff22cf8f58e85cc81" +} diff --git a/rust/.sqlx/query-2bd3251126625d8dd5143f58f4f9c4bbd0c3a17b7ea65767cf5e7512e5a6ea89.json b/rust/.sqlx/query-2bd3251126625d8dd5143f58f4f9c4bbd0c3a17b7ea65767cf5e7512e5a6ea89.json index cfcbdd6288f56..1bdb0efcc34ed 100644 --- a/rust/.sqlx/query-2bd3251126625d8dd5143f58f4f9c4bbd0c3a17b7ea65767cf5e7512e5a6ea89.json +++ b/rust/.sqlx/query-2bd3251126625d8dd5143f58f4f9c4bbd0c3a17b7ea65767cf5e7512e5a6ea89.json @@ -1,18 +1,23 @@ { - "db_name": "PostgreSQL", - "query": "UPDATE cyclotron_jobs SET state = 'running', lock_id = $1, last_heartbeat=NOW() WHERE id = $2 returning queue_name", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "queue_name", - "type_info": "Text" - } - ], - "parameters": { - "Left": ["Uuid", "Uuid"] - }, - "nullable": [false] + "db_name": "PostgreSQL", + "query": "UPDATE cyclotron_jobs SET state = 'running', lock_id = $1, last_heartbeat=NOW() WHERE id = $2 returning queue_name", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "queue_name", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] }, - "hash": "2bd3251126625d8dd5143f58f4f9c4bbd0c3a17b7ea65767cf5e7512e5a6ea89" + "nullable": [ + false + ] + }, + "hash": "2bd3251126625d8dd5143f58f4f9c4bbd0c3a17b7ea65767cf5e7512e5a6ea89" } diff --git a/rust/.sqlx/query-2ca9ea5e8706bba21b14d9a349f3d0e39f01b19b243d724b09f3ce6617d03dc7.json b/rust/.sqlx/query-2ca9ea5e8706bba21b14d9a349f3d0e39f01b19b243d724b09f3ce6617d03dc7.json index e69786b54b25e..affa061018ed2 100644 --- a/rust/.sqlx/query-2ca9ea5e8706bba21b14d9a349f3d0e39f01b19b243d724b09f3ce6617d03dc7.json +++ b/rust/.sqlx/query-2ca9ea5e8706bba21b14d9a349f3d0e39f01b19b243d724b09f3ce6617d03dc7.json @@ -1,12 +1,15 @@ { - "db_name": "PostgreSQL", - "query": "UPDATE cyclotron_jobs SET state = 'available', lock_id = NULL, queue_name = $1 WHERE id = $2", - "describe": { - "columns": [], - "parameters": { - "Left": ["Text", "Uuid"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "UPDATE cyclotron_jobs SET state = 'available', lock_id = NULL, queue_name = $1 WHERE id = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Uuid" + ] }, - "hash": "2ca9ea5e8706bba21b14d9a349f3d0e39f01b19b243d724b09f3ce6617d03dc7" + "nullable": [] + }, + "hash": "2ca9ea5e8706bba21b14d9a349f3d0e39f01b19b243d724b09f3ce6617d03dc7" } diff --git a/rust/.sqlx/query-361eb26d51d253242a8af33e45d8686c4393f6420e61b6b141143974ff362213.json b/rust/.sqlx/query-361eb26d51d253242a8af33e45d8686c4393f6420e61b6b141143974ff362213.json index 7a0918905c0e7..8ea73c5d64197 100644 --- a/rust/.sqlx/query-361eb26d51d253242a8af33e45d8686c4393f6420e61b6b141143974ff362213.json +++ b/rust/.sqlx/query-361eb26d51d253242a8af33e45d8686c4393f6420e61b6b141143974ff362213.json @@ -1,43 +1,53 @@ { - "db_name": "PostgreSQL", - "query": "SELECT id, team_id, ref as set_ref, storage_ptr, created_at, failure_reason\n FROM posthog_errortrackingsymbolset\n WHERE team_id = $1 AND ref = $2", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "team_id", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "set_ref", - "type_info": "Text" - }, - { - "ordinal": 3, - "name": "storage_ptr", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 5, - "name": "failure_reason", - "type_info": "Text" - } - ], - "parameters": { - "Left": ["Int4", "Text"] - }, - "nullable": [false, false, false, true, false, true] + "db_name": "PostgreSQL", + "query": "SELECT id, team_id, ref as set_ref, storage_ptr, created_at, failure_reason\n FROM posthog_errortrackingsymbolset\n WHERE team_id = $1 AND ref = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "team_id", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "set_ref", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "storage_ptr", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 5, + "name": "failure_reason", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Int4", + "Text" + ] }, - "hash": "361eb26d51d253242a8af33e45d8686c4393f6420e61b6b141143974ff362213" + "nullable": [ + false, + false, + false, + true, + false, + true + ] + }, + "hash": "361eb26d51d253242a8af33e45d8686c4393f6420e61b6b141143974ff362213" } diff --git a/rust/.sqlx/query-385e94f4adab0f85174968f6eee873bf6d1d43884cd628df5b36978dd761b025.json b/rust/.sqlx/query-385e94f4adab0f85174968f6eee873bf6d1d43884cd628df5b36978dd761b025.json index 5c6b66d3f8739..89a968bc01027 100644 --- a/rust/.sqlx/query-385e94f4adab0f85174968f6eee873bf6d1d43884cd628df5b36978dd761b025.json +++ b/rust/.sqlx/query-385e94f4adab0f85174968f6eee873bf6d1d43884cd628df5b36978dd761b025.json @@ -1,18 +1,23 @@ { - "db_name": "PostgreSQL", - "query": "\nSELECT id FROM cyclotron_jobs WHERE state = 'running' AND COALESCE(last_heartbeat, $1) <= $1 AND janitor_touch_count >= $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - } - ], - "parameters": { - "Left": ["Timestamptz", "Int2"] - }, - "nullable": [false] + "db_name": "PostgreSQL", + "query": "\nSELECT id FROM cyclotron_jobs WHERE state = 'running' AND COALESCE(last_heartbeat, $1) <= $1 AND janitor_touch_count >= $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Timestamptz", + "Int2" + ] }, - "hash": "385e94f4adab0f85174968f6eee873bf6d1d43884cd628df5b36978dd761b025" + "nullable": [ + false + ] + }, + "hash": "385e94f4adab0f85174968f6eee873bf6d1d43884cd628df5b36978dd761b025" } diff --git a/rust/.sqlx/query-42e393046a686e6a69daa920dc2ab521aa6f393027c399a0c40139f5f8a0a45e.json b/rust/.sqlx/query-42e393046a686e6a69daa920dc2ab521aa6f393027c399a0c40139f5f8a0a45e.json index aa1ff7e7cf3e1..890675aa24d0d 100644 --- a/rust/.sqlx/query-42e393046a686e6a69daa920dc2ab521aa6f393027c399a0c40139f5f8a0a45e.json +++ b/rust/.sqlx/query-42e393046a686e6a69daa920dc2ab521aa6f393027c399a0c40139f5f8a0a45e.json @@ -1,12 +1,16 @@ { - "db_name": "PostgreSQL", - "query": "INSERT INTO posthog_eventproperty (event, property, team_id) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING", - "describe": { - "columns": [], - "parameters": { - "Left": ["Varchar", "Varchar", "Int4"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "INSERT INTO posthog_eventproperty (event, property, team_id) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Varchar", + "Int4" + ] }, - "hash": "42e393046a686e6a69daa920dc2ab521aa6f393027c399a0c40139f5f8a0a45e" + "nullable": [] + }, + "hash": "42e393046a686e6a69daa920dc2ab521aa6f393027c399a0c40139f5f8a0a45e" } diff --git a/rust/.sqlx/query-44eb698252059821770eaaf5b8213132c3e7bf297834cd42228b35bf3e424dd7.json b/rust/.sqlx/query-44eb698252059821770eaaf5b8213132c3e7bf297834cd42228b35bf3e424dd7.json deleted file mode 100644 index 8d5f49a073584..0000000000000 --- a/rust/.sqlx/query-44eb698252059821770eaaf5b8213132c3e7bf297834cd42228b35bf3e424dd7.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO posthog_errortrackingissue (id, team_id, status, created_at)\n VALUES ($1, $2, $3, NOW())\n ON CONFLICT (id) DO NOTHING\n RETURNING (xmax = 0) AS was_inserted\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "was_inserted", - "type_info": "Bool" - } - ], - "parameters": { - "Left": ["Uuid", "Int4", "Text"] - }, - "nullable": [null] - }, - "hash": "44eb698252059821770eaaf5b8213132c3e7bf297834cd42228b35bf3e424dd7" -} diff --git a/rust/.sqlx/query-4b24f800767bc20852115e7406f8dc46c18f4950a7951d2c412dcba4d13fb56b.json b/rust/.sqlx/query-4b24f800767bc20852115e7406f8dc46c18f4950a7951d2c412dcba4d13fb56b.json index 1f374d8084cf1..515f058fad974 100644 --- a/rust/.sqlx/query-4b24f800767bc20852115e7406f8dc46c18f4950a7951d2c412dcba4d13fb56b.json +++ b/rust/.sqlx/query-4b24f800767bc20852115e7406f8dc46c18f4950a7951d2c412dcba4d13fb56b.json @@ -1,48 +1,59 @@ { - "db_name": "PostgreSQL", - "query": "\n SELECT raw_id, team_id, created_at, symbol_set_id, contents, resolved, context\n FROM posthog_errortrackingstackframe\n WHERE raw_id = $1 AND team_id = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "raw_id", - "type_info": "Text" - }, - { - "ordinal": 1, - "name": "team_id", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 3, - "name": "symbol_set_id", - "type_info": "Uuid" - }, - { - "ordinal": 4, - "name": "contents", - "type_info": "Jsonb" - }, - { - "ordinal": 5, - "name": "resolved", - "type_info": "Bool" - }, - { - "ordinal": 6, - "name": "context", - "type_info": "Text" - } - ], - "parameters": { - "Left": ["Text", "Int4"] - }, - "nullable": [false, false, false, true, false, false, true] + "db_name": "PostgreSQL", + "query": "\n SELECT raw_id, team_id, created_at, symbol_set_id, contents, resolved, context\n FROM posthog_errortrackingstackframe\n WHERE raw_id = $1 AND team_id = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "raw_id", + "type_info": "Text" + }, + { + "ordinal": 1, + "name": "team_id", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 3, + "name": "symbol_set_id", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "contents", + "type_info": "Jsonb" + }, + { + "ordinal": 5, + "name": "resolved", + "type_info": "Bool" + }, + { + "ordinal": 6, + "name": "context", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Text", + "Int4" + ] }, - "hash": "4b24f800767bc20852115e7406f8dc46c18f4950a7951d2c412dcba4d13fb56b" + "nullable": [ + false, + false, + false, + true, + false, + false, + true + ] + }, + "hash": "4b24f800767bc20852115e7406f8dc46c18f4950a7951d2c412dcba4d13fb56b" } diff --git a/rust/.sqlx/query-54d9afe6952f92b753fbce2c4e8554065b71152389f98d35532c6b332d5a4c9d.json b/rust/.sqlx/query-54d9afe6952f92b753fbce2c4e8554065b71152389f98d35532c6b332d5a4c9d.json index 2ff58c66714a1..6bbfb17e16a20 100644 --- a/rust/.sqlx/query-54d9afe6952f92b753fbce2c4e8554065b71152389f98d35532c6b332d5a4c9d.json +++ b/rust/.sqlx/query-54d9afe6952f92b753fbce2c4e8554065b71152389f98d35532c6b332d5a4c9d.json @@ -1,12 +1,14 @@ { - "db_name": "PostgreSQL", - "query": "\nWITH stalled AS (\n SELECT id FROM cyclotron_jobs WHERE state = 'running' AND COALESCE(last_heartbeat, $1) <= $1 FOR UPDATE SKIP LOCKED\n)\nUPDATE cyclotron_jobs\nSET state = 'available', lock_id = NULL, last_heartbeat = NULL, janitor_touch_count = janitor_touch_count + 1\nFROM stalled\nWHERE cyclotron_jobs.id = stalled.id\n ", - "describe": { - "columns": [], - "parameters": { - "Left": ["Timestamptz"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "\nWITH stalled AS (\n SELECT id FROM cyclotron_jobs WHERE state = 'running' AND COALESCE(last_heartbeat, $1) <= $1 FOR UPDATE SKIP LOCKED\n)\nUPDATE cyclotron_jobs\nSET state = 'available', lock_id = NULL, last_heartbeat = NULL, janitor_touch_count = janitor_touch_count + 1\nFROM stalled\nWHERE cyclotron_jobs.id = stalled.id\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz" + ] }, - "hash": "54d9afe6952f92b753fbce2c4e8554065b71152389f98d35532c6b332d5a4c9d" + "nullable": [] + }, + "hash": "54d9afe6952f92b753fbce2c4e8554065b71152389f98d35532c6b332d5a4c9d" } diff --git a/rust/.sqlx/query-78f54fcebc11e2411008448281e4711bdfb8cf78e362ccda8bc14e92324d51f8.json b/rust/.sqlx/query-78f54fcebc11e2411008448281e4711bdfb8cf78e362ccda8bc14e92324d51f8.json index d70d4c9d33a43..44118c7405233 100644 --- a/rust/.sqlx/query-78f54fcebc11e2411008448281e4711bdfb8cf78e362ccda8bc14e92324d51f8.json +++ b/rust/.sqlx/query-78f54fcebc11e2411008448281e4711bdfb8cf78e362ccda8bc14e92324d51f8.json @@ -1,18 +1,22 @@ { - "db_name": "PostgreSQL", - "query": "SELECT COUNT(*) FROM cyclotron_jobs WHERE queue_name = $1", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "count", - "type_info": "Int8" - } - ], - "parameters": { - "Left": ["Text"] - }, - "nullable": [null] + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM cyclotron_jobs WHERE queue_name = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] }, - "hash": "78f54fcebc11e2411008448281e4711bdfb8cf78e362ccda8bc14e92324d51f8" + "nullable": [ + null + ] + }, + "hash": "78f54fcebc11e2411008448281e4711bdfb8cf78e362ccda8bc14e92324d51f8" } diff --git a/rust/.sqlx/query-917e3d14c15558a1e0bb1d7015ed687eb545ee9d4ccbb8b69c958a357d49f687.json b/rust/.sqlx/query-917e3d14c15558a1e0bb1d7015ed687eb545ee9d4ccbb8b69c958a357d49f687.json index 188cd0be38966..6f3e42a0a8b9b 100644 --- a/rust/.sqlx/query-917e3d14c15558a1e0bb1d7015ed687eb545ee9d4ccbb8b69c958a357d49f687.json +++ b/rust/.sqlx/query-917e3d14c15558a1e0bb1d7015ed687eb545ee9d4ccbb8b69c958a357d49f687.json @@ -1,12 +1,17 @@ { - "db_name": "PostgreSQL", - "query": "\n INSERT INTO posthog_eventdefinition (id, name, volume_30_day, query_usage_30_day, team_id, last_seen_at, created_at)\n VALUES ($1, $2, NULL, NULL, $3, $4, NOW()) ON CONFLICT\n ON CONSTRAINT posthog_eventdefinition_team_id_name_80fa0b87_uniq\n DO UPDATE SET last_seen_at = $4\n ", - "describe": { - "columns": [], - "parameters": { - "Left": ["Uuid", "Varchar", "Int4", "Timestamptz"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "\n INSERT INTO posthog_eventdefinition (id, name, volume_30_day, query_usage_30_day, team_id, last_seen_at, created_at)\n VALUES ($1, $2, NULL, NULL, $3, $4, NOW()) ON CONFLICT\n ON CONSTRAINT posthog_eventdefinition_team_id_name_80fa0b87_uniq\n DO UPDATE SET last_seen_at = $4\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Int4", + "Timestamptz" + ] }, - "hash": "917e3d14c15558a1e0bb1d7015ed687eb545ee9d4ccbb8b69c958a357d49f687" + "nullable": [] + }, + "hash": "917e3d14c15558a1e0bb1d7015ed687eb545ee9d4ccbb8b69c958a357d49f687" } diff --git a/rust/.sqlx/query-aa595eaf28c1f4b872c278be407b59cc00f3125413f4032ac3647a6b5ee1a632.json b/rust/.sqlx/query-aa595eaf28c1f4b872c278be407b59cc00f3125413f4032ac3647a6b5ee1a632.json index 51fb1b018120b..244f029a6a431 100644 --- a/rust/.sqlx/query-aa595eaf28c1f4b872c278be407b59cc00f3125413f4032ac3647a6b5ee1a632.json +++ b/rust/.sqlx/query-aa595eaf28c1f4b872c278be407b59cc00f3125413f4032ac3647a6b5ee1a632.json @@ -1,18 +1,23 @@ { - "db_name": "PostgreSQL", - "query": "SELECT vm_state FROM cyclotron_jobs WHERE id = $1 AND lock_id = $2", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "vm_state", - "type_info": "Bytea" - } - ], - "parameters": { - "Left": ["Uuid", "Uuid"] - }, - "nullable": [true] + "db_name": "PostgreSQL", + "query": "SELECT vm_state FROM cyclotron_jobs WHERE id = $1 AND lock_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "vm_state", + "type_info": "Bytea" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] }, - "hash": "aa595eaf28c1f4b872c278be407b59cc00f3125413f4032ac3647a6b5ee1a632" + "nullable": [ + true + ] + }, + "hash": "aa595eaf28c1f4b872c278be407b59cc00f3125413f4032ac3647a6b5ee1a632" } diff --git a/rust/.sqlx/query-ad528f712bdaf75a82293018e3dec3544acd0228776b8535f22438db59002e1f.json b/rust/.sqlx/query-ad528f712bdaf75a82293018e3dec3544acd0228776b8535f22438db59002e1f.json deleted file mode 100644 index 1f2ff6b906965..0000000000000 --- a/rust/.sqlx/query-ad528f712bdaf75a82293018e3dec3544acd0228776b8535f22438db59002e1f.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT id, team_id, status FROM posthog_errortrackingissue\n WHERE team_id = $1 AND id = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "team_id", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "status", - "type_info": "Text" - } - ], - "parameters": { - "Left": ["Int4", "Uuid"] - }, - "nullable": [false, false, false] - }, - "hash": "ad528f712bdaf75a82293018e3dec3544acd0228776b8535f22438db59002e1f" -} diff --git a/rust/.sqlx/query-b420ccc79fa7847f65246adf76a074995829d1372fe8ec1fd683f9524bcebb8b.json b/rust/.sqlx/query-b420ccc79fa7847f65246adf76a074995829d1372fe8ec1fd683f9524bcebb8b.json index ed79a7102f52f..8a40f0f253f2e 100644 --- a/rust/.sqlx/query-b420ccc79fa7847f65246adf76a074995829d1372fe8ec1fd683f9524bcebb8b.json +++ b/rust/.sqlx/query-b420ccc79fa7847f65246adf76a074995829d1372fe8ec1fd683f9524bcebb8b.json @@ -1,23 +1,26 @@ { - "db_name": "PostgreSQL", - "query": "SELECT COUNT(*), queue_name FROM cyclotron_jobs WHERE state = 'available' AND scheduled <= NOW() GROUP BY queue_name", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "count", - "type_info": "Int8" - }, - { - "ordinal": 1, - "name": "queue_name", - "type_info": "Text" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [null, false] + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*), queue_name FROM cyclotron_jobs WHERE state = 'available' AND scheduled <= NOW() GROUP BY queue_name", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "queue_name", + "type_info": "Text" + } + ], + "parameters": { + "Left": [] }, - "hash": "b420ccc79fa7847f65246adf76a074995829d1372fe8ec1fd683f9524bcebb8b" + "nullable": [ + null, + false + ] + }, + "hash": "b420ccc79fa7847f65246adf76a074995829d1372fe8ec1fd683f9524bcebb8b" } diff --git a/rust/.sqlx/query-b8c1b723826d595dca0389d729fa76bd8a7d96d73983a0c408f32f17da5f483b.json b/rust/.sqlx/query-b8c1b723826d595dca0389d729fa76bd8a7d96d73983a0c408f32f17da5f483b.json index 8f201d80503ce..7733c346c4b72 100644 --- a/rust/.sqlx/query-b8c1b723826d595dca0389d729fa76bd8a7d96d73983a0c408f32f17da5f483b.json +++ b/rust/.sqlx/query-b8c1b723826d595dca0389d729fa76bd8a7d96d73983a0c408f32f17da5f483b.json @@ -1,12 +1,16 @@ { - "db_name": "PostgreSQL", - "query": "INSERT INTO cyclotron_dead_letter_metadata (job_id, original_queue_name, reason, dlq_time) VALUES ($1, $2, $3, NOW())", - "describe": { - "columns": [], - "parameters": { - "Left": ["Uuid", "Text", "Text"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "INSERT INTO cyclotron_dead_letter_metadata (job_id, original_queue_name, reason, dlq_time) VALUES ($1, $2, $3, NOW())", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Text" + ] }, - "hash": "b8c1b723826d595dca0389d729fa76bd8a7d96d73983a0c408f32f17da5f483b" + "nullable": [] + }, + "hash": "b8c1b723826d595dca0389d729fa76bd8a7d96d73983a0c408f32f17da5f483b" } diff --git a/rust/.sqlx/query-c6ff00fcbbc77c8f5c1b3fe2f3352ea79485e403b9e17b6c37259ea0612065ee.json b/rust/.sqlx/query-c6ff00fcbbc77c8f5c1b3fe2f3352ea79485e403b9e17b6c37259ea0612065ee.json index f6ad8e4e89247..608008e09adb5 100644 --- a/rust/.sqlx/query-c6ff00fcbbc77c8f5c1b3fe2f3352ea79485e403b9e17b6c37259ea0612065ee.json +++ b/rust/.sqlx/query-c6ff00fcbbc77c8f5c1b3fe2f3352ea79485e403b9e17b6c37259ea0612065ee.json @@ -1,18 +1,23 @@ { - "db_name": "PostgreSQL", - "query": "SELECT group_type_index FROM posthog_grouptypemapping WHERE group_type = $1 AND team_id = $2", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "group_type_index", - "type_info": "Int4" - } - ], - "parameters": { - "Left": ["Text", "Int4"] - }, - "nullable": [false] + "db_name": "PostgreSQL", + "query": "SELECT group_type_index FROM posthog_grouptypemapping WHERE group_type = $1 AND team_id = $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "group_type_index", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text", + "Int4" + ] }, - "hash": "c6ff00fcbbc77c8f5c1b3fe2f3352ea79485e403b9e17b6c37259ea0612065ee" + "nullable": [ + false + ] + }, + "hash": "c6ff00fcbbc77c8f5c1b3fe2f3352ea79485e403b9e17b6c37259ea0612065ee" } diff --git a/rust/.sqlx/query-ce036f16a37a41b9dc5a164de0b52345454cd3323568c4bef5b8480380287068.json b/rust/.sqlx/query-ce036f16a37a41b9dc5a164de0b52345454cd3323568c4bef5b8480380287068.json index fe174820c3a07..d996dae8bd444 100644 --- a/rust/.sqlx/query-ce036f16a37a41b9dc5a164de0b52345454cd3323568c4bef5b8480380287068.json +++ b/rust/.sqlx/query-ce036f16a37a41b9dc5a164de0b52345454cd3323568c4bef5b8480380287068.json @@ -1,123 +1,133 @@ { - "db_name": "PostgreSQL", - "query": "\nWITH available AS (\n SELECT\n id,\n state\n FROM cyclotron_jobs\n WHERE\n state = 'available'::JobState\n AND queue_name = $1\n AND scheduled <= NOW()\n ORDER BY\n priority ASC,\n scheduled ASC\n LIMIT $2\n FOR UPDATE SKIP LOCKED\n)\nUPDATE cyclotron_jobs\nSET\n state = 'running'::JobState,\n lock_id = $3,\n last_heartbeat = NOW(),\n last_transition = NOW(),\n transition_count = transition_count + 1\nFROM available\nWHERE\n cyclotron_jobs.id = available.id\nRETURNING\n cyclotron_jobs.id,\n team_id,\n available.state as \"state: JobState\",\n queue_name,\n priority,\n function_id,\n created,\n last_transition,\n scheduled,\n transition_count,\n vm_state,\n metadata,\n parameters,\n blob,\n lock_id,\n last_heartbeat,\n janitor_touch_count\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "team_id", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "state: JobState", - "type_info": { - "Custom": { - "name": "jobstate", - "kind": { - "Enum": ["available", "completed", "failed", "running", "paused"] - } - } - } - }, - { - "ordinal": 3, - "name": "queue_name", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "priority", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "function_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "created", - "type_info": "Timestamptz" - }, - { - "ordinal": 7, - "name": "last_transition", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "scheduled", - "type_info": "Timestamptz" - }, - { - "ordinal": 9, - "name": "transition_count", - "type_info": "Int2" - }, - { - "ordinal": 10, - "name": "vm_state", - "type_info": "Bytea" - }, - { - "ordinal": 11, - "name": "metadata", - "type_info": "Bytea" - }, - { - "ordinal": 12, - "name": "parameters", - "type_info": "Bytea" - }, - { - "ordinal": 13, - "name": "blob", - "type_info": "Bytea" - }, - { - "ordinal": 14, - "name": "lock_id", - "type_info": "Uuid" - }, - { - "ordinal": 15, - "name": "last_heartbeat", - "type_info": "Timestamptz" - }, - { - "ordinal": 16, - "name": "janitor_touch_count", - "type_info": "Int2" + "db_name": "PostgreSQL", + "query": "\nWITH available AS (\n SELECT\n id,\n state\n FROM cyclotron_jobs\n WHERE\n state = 'available'::JobState\n AND queue_name = $1\n AND scheduled <= NOW()\n ORDER BY\n priority ASC,\n scheduled ASC\n LIMIT $2\n FOR UPDATE SKIP LOCKED\n)\nUPDATE cyclotron_jobs\nSET\n state = 'running'::JobState,\n lock_id = $3,\n last_heartbeat = NOW(),\n last_transition = NOW(),\n transition_count = transition_count + 1\nFROM available\nWHERE\n cyclotron_jobs.id = available.id\nRETURNING\n cyclotron_jobs.id,\n team_id,\n available.state as \"state: JobState\",\n queue_name,\n priority,\n function_id,\n created,\n last_transition,\n scheduled,\n transition_count,\n vm_state,\n metadata,\n parameters,\n blob,\n lock_id,\n last_heartbeat,\n janitor_touch_count\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "team_id", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "state: JobState", + "type_info": { + "Custom": { + "name": "jobstate", + "kind": { + "Enum": [ + "available", + "completed", + "failed", + "running", + "paused" + ] } - ], - "parameters": { - "Left": ["Text", "Int8", "Uuid"] - }, - "nullable": [ - false, - false, - false, - false, - false, - true, - false, - false, - false, - false, - true, - true, - true, - true, - true, - true, - false - ] + } + } + }, + { + "ordinal": 3, + "name": "queue_name", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "priority", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "function_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "created", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "last_transition", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "scheduled", + "type_info": "Timestamptz" + }, + { + "ordinal": 9, + "name": "transition_count", + "type_info": "Int2" + }, + { + "ordinal": 10, + "name": "vm_state", + "type_info": "Bytea" + }, + { + "ordinal": 11, + "name": "metadata", + "type_info": "Bytea" + }, + { + "ordinal": 12, + "name": "parameters", + "type_info": "Bytea" + }, + { + "ordinal": 13, + "name": "blob", + "type_info": "Bytea" + }, + { + "ordinal": 14, + "name": "lock_id", + "type_info": "Uuid" + }, + { + "ordinal": 15, + "name": "last_heartbeat", + "type_info": "Timestamptz" + }, + { + "ordinal": 16, + "name": "janitor_touch_count", + "type_info": "Int2" + } + ], + "parameters": { + "Left": [ + "Text", + "Int8", + "Uuid" + ] }, - "hash": "ce036f16a37a41b9dc5a164de0b52345454cd3323568c4bef5b8480380287068" + "nullable": [ + false, + false, + false, + false, + false, + true, + false, + false, + false, + false, + true, + true, + true, + true, + true, + true, + false + ] + }, + "hash": "ce036f16a37a41b9dc5a164de0b52345454cd3323568c4bef5b8480380287068" } diff --git a/rust/.sqlx/query-e0c6790eccd2e7505d86ed570f093c27fdf4d88145cd7eaf4bbd39e49a7452f6.json b/rust/.sqlx/query-e0c6790eccd2e7505d86ed570f093c27fdf4d88145cd7eaf4bbd39e49a7452f6.json new file mode 100644 index 0000000000000..a0513cd7b428f --- /dev/null +++ b/rust/.sqlx/query-e0c6790eccd2e7505d86ed570f093c27fdf4d88145cd7eaf4bbd39e49a7452f6.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO posthog_errortrackingissue (id, team_id, status, name, description, created_at)\n VALUES ($1, $2, $3, $4, $5, NOW())\n ON CONFLICT (id) DO NOTHING\n RETURNING (xmax = 0) AS was_inserted\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "was_inserted", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int4", + "Text", + "Text", + "Text" + ] + }, + "nullable": [ + null + ] + }, + "hash": "e0c6790eccd2e7505d86ed570f093c27fdf4d88145cd7eaf4bbd39e49a7452f6" +} diff --git a/rust/.sqlx/query-e842f1ed33747bde4570c6d861d856c4cbd8beb519df8212212017dda9d06c51.json b/rust/.sqlx/query-e842f1ed33747bde4570c6d861d856c4cbd8beb519df8212212017dda9d06c51.json index 145fe9bf7bc9f..de7157b9b0ae2 100644 --- a/rust/.sqlx/query-e842f1ed33747bde4570c6d861d856c4cbd8beb519df8212212017dda9d06c51.json +++ b/rust/.sqlx/query-e842f1ed33747bde4570c6d861d856c4cbd8beb519df8212212017dda9d06c51.json @@ -1,38 +1,44 @@ { - "db_name": "PostgreSQL", - "query": "\nWITH to_delete AS (\n DELETE FROM cyclotron_jobs\n WHERE state IN ('failed', 'completed')\n RETURNING last_transition, team_id, function_id::text, state::text\n),\naggregated_data AS (\n SELECT\n date_trunc('hour', last_transition) AS hour,\n team_id,\n function_id,\n state,\n COUNT(*) AS count\n FROM to_delete\n GROUP BY hour, team_id, function_id, state\n)\nSELECT\n hour as \"hour!\",\n team_id as \"team_id!\",\n function_id,\n state as \"state!\",\n count as \"count!\"\nFROM aggregated_data", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "hour!", - "type_info": "Timestamptz" - }, - { - "ordinal": 1, - "name": "team_id!", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "function_id", - "type_info": "Text" - }, - { - "ordinal": 3, - "name": "state!", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "count!", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [null, false, null, null, null] + "db_name": "PostgreSQL", + "query": "\nWITH to_delete AS (\n DELETE FROM cyclotron_jobs\n WHERE state IN ('failed', 'completed')\n RETURNING last_transition, team_id, function_id::text, state::text\n),\naggregated_data AS (\n SELECT\n date_trunc('hour', last_transition) AS hour,\n team_id,\n function_id,\n state,\n COUNT(*) AS count\n FROM to_delete\n GROUP BY hour, team_id, function_id, state\n)\nSELECT\n hour as \"hour!\",\n team_id as \"team_id!\",\n function_id,\n state as \"state!\",\n count as \"count!\"\nFROM aggregated_data", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "hour!", + "type_info": "Timestamptz" + }, + { + "ordinal": 1, + "name": "team_id!", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "function_id", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "state!", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "count!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] }, - "hash": "e842f1ed33747bde4570c6d861d856c4cbd8beb519df8212212017dda9d06c51" + "nullable": [ + null, + false, + null, + null, + null + ] + }, + "hash": "e842f1ed33747bde4570c6d861d856c4cbd8beb519df8212212017dda9d06c51" } diff --git a/rust/.sqlx/query-eecef0ce664dfe65dff4452d92a29c948a291ea8218bbbb4e25cd1ad36dbe9f4.json b/rust/.sqlx/query-eecef0ce664dfe65dff4452d92a29c948a291ea8218bbbb4e25cd1ad36dbe9f4.json index 78ca221cb2f49..a54bb9565ea4f 100644 --- a/rust/.sqlx/query-eecef0ce664dfe65dff4452d92a29c948a291ea8218bbbb4e25cd1ad36dbe9f4.json +++ b/rust/.sqlx/query-eecef0ce664dfe65dff4452d92a29c948a291ea8218bbbb4e25cd1ad36dbe9f4.json @@ -1,12 +1,20 @@ { - "db_name": "PostgreSQL", - "query": "\n INSERT INTO posthog_propertydefinition (id, name, type, group_type_index, is_numerical, volume_30_day, query_usage_30_day, team_id, property_type)\n VALUES ($1, $2, $3, $4, $5, NULL, NULL, $6, $7)\n ON CONFLICT (team_id, name, type, coalesce(group_type_index, -1))\n DO UPDATE SET property_type=EXCLUDED.property_type WHERE posthog_propertydefinition.property_type IS NULL\n ", - "describe": { - "columns": [], - "parameters": { - "Left": ["Uuid", "Varchar", "Int2", "Int2", "Bool", "Int4", "Varchar"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "\n INSERT INTO posthog_propertydefinition (id, name, type, group_type_index, is_numerical, volume_30_day, query_usage_30_day, team_id, property_type)\n VALUES ($1, $2, $3, $4, $5, NULL, NULL, $6, $7)\n ON CONFLICT (team_id, name, type, coalesce(group_type_index, -1))\n DO UPDATE SET property_type=EXCLUDED.property_type WHERE posthog_propertydefinition.property_type IS NULL\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Int2", + "Int2", + "Bool", + "Int4", + "Varchar" + ] }, - "hash": "eecef0ce664dfe65dff4452d92a29c948a291ea8218bbbb4e25cd1ad36dbe9f4" + "nullable": [] + }, + "hash": "eecef0ce664dfe65dff4452d92a29c948a291ea8218bbbb4e25cd1ad36dbe9f4" } diff --git a/rust/.sqlx/query-f074766d1fc32df17f92667f412af30c682288988fc6f102e8a063be97c3e51c.json b/rust/.sqlx/query-f074766d1fc32df17f92667f412af30c682288988fc6f102e8a063be97c3e51c.json index 6139be53026c1..4f91e01e690bc 100644 --- a/rust/.sqlx/query-f074766d1fc32df17f92667f412af30c682288988fc6f102e8a063be97c3e51c.json +++ b/rust/.sqlx/query-f074766d1fc32df17f92667f412af30c682288988fc6f102e8a063be97c3e51c.json @@ -1,31 +1,37 @@ { - "db_name": "PostgreSQL", - "query": "\nINSERT INTO cyclotron_jobs\n (\n id,\n team_id,\n function_id,\n created,\n lock_id,\n last_heartbeat,\n janitor_touch_count,\n transition_count,\n last_transition,\n queue_name,\n state,\n scheduled,\n priority,\n vm_state,\n metadata,\n parameters,\n blob\n )\nVALUES\n ($1, $2, $3, NOW(), NULL, NULL, 0, 0, NOW(), $4, $5, $6, $7, $8, $9, $10, $11)\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Int4", - "Uuid", - "Text", - { - "Custom": { - "name": "jobstate", - "kind": { - "Enum": ["available", "completed", "failed", "running", "paused"] - } - } - }, - "Timestamptz", - "Int2", - "Bytea", - "Bytea", - "Bytea", - "Bytea" - ] + "db_name": "PostgreSQL", + "query": "\nINSERT INTO cyclotron_jobs\n (\n id,\n team_id,\n function_id,\n created,\n lock_id,\n last_heartbeat,\n janitor_touch_count,\n transition_count,\n last_transition,\n queue_name,\n state,\n scheduled,\n priority,\n vm_state,\n metadata,\n parameters,\n blob\n )\nVALUES\n ($1, $2, $3, NOW(), NULL, NULL, 0, 0, NOW(), $4, $5, $6, $7, $8, $9, $10, $11)\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Int4", + "Uuid", + "Text", + { + "Custom": { + "name": "jobstate", + "kind": { + "Enum": [ + "available", + "completed", + "failed", + "running", + "paused" + ] + } + } }, - "nullable": [] + "Timestamptz", + "Int2", + "Bytea", + "Bytea", + "Bytea", + "Bytea" + ] }, - "hash": "f074766d1fc32df17f92667f412af30c682288988fc6f102e8a063be97c3e51c" + "nullable": [] + }, + "hash": "f074766d1fc32df17f92667f412af30c682288988fc6f102e8a063be97c3e51c" } diff --git a/rust/.sqlx/query-fd6745e4ed7575699286d9828c9f6c959ba804dab9c1e5ba39979d19782582ea.json b/rust/.sqlx/query-fd6745e4ed7575699286d9828c9f6c959ba804dab9c1e5ba39979d19782582ea.json index 698578f72873a..791e4ca71354d 100644 --- a/rust/.sqlx/query-fd6745e4ed7575699286d9828c9f6c959ba804dab9c1e5ba39979d19782582ea.json +++ b/rust/.sqlx/query-fd6745e4ed7575699286d9828c9f6c959ba804dab9c1e5ba39979d19782582ea.json @@ -1,38 +1,49 @@ { - "db_name": "PostgreSQL", - "query": "\n INSERT INTO posthog_errortrackingissuefingerprintv2 (id, team_id, issue_id, fingerprint, version, created_at)\n VALUES ($1, $2, $3, $4, 0, NOW())\n ON CONFLICT (team_id, fingerprint) DO NOTHING\n RETURNING id, team_id, issue_id, fingerprint, version\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "team_id", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "issue_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "fingerprint", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "version", - "type_info": "Int8" - } - ], - "parameters": { - "Left": ["Uuid", "Int4", "Uuid", "Text"] - }, - "nullable": [false, false, false, false, false] + "db_name": "PostgreSQL", + "query": "\n INSERT INTO posthog_errortrackingissuefingerprintv2 (id, team_id, issue_id, fingerprint, version, created_at)\n VALUES ($1, $2, $3, $4, 0, NOW())\n ON CONFLICT (team_id, fingerprint) DO NOTHING\n RETURNING id, team_id, issue_id, fingerprint, version\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "team_id", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "issue_id", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "fingerprint", + "type_info": "Text" + }, + { + "ordinal": 4, + "name": "version", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int4", + "Uuid", + "Text" + ] }, - "hash": "fd6745e4ed7575699286d9828c9f6c959ba804dab9c1e5ba39979d19782582ea" + "nullable": [ + false, + false, + false, + false, + false + ] + }, + "hash": "fd6745e4ed7575699286d9828c9f6c959ba804dab9c1e5ba39979d19782582ea" } diff --git a/rust/.sqlx/query-fda1f4ef877d1a71dbb6345d71c21c0eae35356f7b92e969a12a839b41cd360a.json b/rust/.sqlx/query-fda1f4ef877d1a71dbb6345d71c21c0eae35356f7b92e969a12a839b41cd360a.json index 631e5d2d017b8..da2b7d92cb961 100644 --- a/rust/.sqlx/query-fda1f4ef877d1a71dbb6345d71c21c0eae35356f7b92e969a12a839b41cd360a.json +++ b/rust/.sqlx/query-fda1f4ef877d1a71dbb6345d71c21c0eae35356f7b92e969a12a839b41cd360a.json @@ -1,12 +1,19 @@ { - "db_name": "PostgreSQL", - "query": "INSERT INTO posthog_errortrackingsymbolset (id, team_id, ref, storage_ptr, failure_reason, created_at)\n VALUES ($1, $2, $3, $4, $5, $6)\n ON CONFLICT (team_id, ref) DO UPDATE SET storage_ptr = $4", - "describe": { - "columns": [], - "parameters": { - "Left": ["Uuid", "Int4", "Text", "Text", "Text", "Timestamptz"] - }, - "nullable": [] + "db_name": "PostgreSQL", + "query": "INSERT INTO posthog_errortrackingsymbolset (id, team_id, ref, storage_ptr, failure_reason, created_at)\n VALUES ($1, $2, $3, $4, $5, $6)\n ON CONFLICT (team_id, ref) DO UPDATE SET storage_ptr = $4", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Int4", + "Text", + "Text", + "Text", + "Timestamptz" + ] }, - "hash": "fda1f4ef877d1a71dbb6345d71c21c0eae35356f7b92e969a12a839b41cd360a" + "nullable": [] + }, + "hash": "fda1f4ef877d1a71dbb6345d71c21c0eae35356f7b92e969a12a839b41cd360a" } diff --git a/rust/cymbal/src/frames/resolver.rs b/rust/cymbal/src/frames/resolver.rs index b36d00fee6f4e..5e6cafce14055 100644 --- a/rust/cymbal/src/frames/resolver.rs +++ b/rust/cymbal/src/frames/resolver.rs @@ -82,7 +82,7 @@ mod test { sourcemap::SourcemapProvider, Catalog, S3Client, }, - types::{ErrProps, Stacktrace}, + types::{RawErrProps, Stacktrace}, }; const CHUNK_PATH: &str = "/static/chunk-PGUQKT6S.js"; @@ -131,10 +131,10 @@ mod test { fn get_test_frame(server: &MockServer) -> RawFrame { let exception: ClickHouseEvent = serde_json::from_str(EXAMPLE_EXCEPTION).unwrap(); - let props: ErrProps = serde_json::from_str(&exception.properties.unwrap()).unwrap(); + let mut props: RawErrProps = serde_json::from_str(&exception.properties.unwrap()).unwrap(); let Stacktrace::Raw { frames: mut test_stack, - } = props.exception_list.unwrap().swap_remove(0).stack.unwrap() + } = props.exception_list.swap_remove(0).stack.unwrap() else { panic!("Expected a Raw stacktrace") }; diff --git a/rust/cymbal/src/issue_resolution.rs b/rust/cymbal/src/issue_resolution.rs index 3d7ab3ddd6ac1..6778ff100129d 100644 --- a/rust/cymbal/src/issue_resolution.rs +++ b/rust/cymbal/src/issue_resolution.rs @@ -1,7 +1,10 @@ use sqlx::postgres::any::AnyConnectionBackend; use uuid::Uuid; -use crate::error::UnhandledError; +use crate::{ + error::UnhandledError, + types::{FingerprintedErrProps, OutputErrProps}, +}; pub struct IssueFingerprintOverride { pub id: Uuid, @@ -15,14 +18,18 @@ pub struct Issue { pub id: Uuid, pub team_id: i32, pub status: String, + pub name: Option, + pub description: Option, } impl Issue { - pub fn new(team_id: i32) -> Self { + pub fn new(team_id: i32, name: String, description: String) -> Self { Self { id: Uuid::new_v4(), team_id, status: "active".to_string(), // TODO - we should at some point use an enum here + name: Some(name), + description: Some(description), } } @@ -37,7 +44,7 @@ impl Issue { let res = sqlx::query_as!( Issue, r#" - SELECT id, team_id, status FROM posthog_errortrackingissue + SELECT id, team_id, status, name, description FROM posthog_errortrackingissue WHERE team_id = $1 AND id = $2 "#, team_id, @@ -55,14 +62,16 @@ impl Issue { { let did_insert = sqlx::query_scalar!( r#" - INSERT INTO posthog_errortrackingissue (id, team_id, status, created_at) - VALUES ($1, $2, $3, NOW()) + INSERT INTO posthog_errortrackingissue (id, team_id, status, name, description, created_at) + VALUES ($1, $2, $3, $4, $5, NOW()) ON CONFLICT (id) DO NOTHING RETURNING (xmax = 0) AS was_inserted "#, self.id, self.team_id, - self.status + self.status, + self.name, + self.description ) .fetch_one(executor) .await?; @@ -127,30 +136,40 @@ impl IssueFingerprintOverride { pub async fn resolve_issue<'c, A>( con: A, - fingerprint: &str, team_id: i32, -) -> Result + fingerprinted: FingerprintedErrProps, +) -> Result where A: sqlx::Acquire<'c, Database = sqlx::Postgres>, { let mut conn = con.acquire().await?; // If an override already exists, just fast-path, skipping the transaction if let Some(issue_override) = - IssueFingerprintOverride::load(&mut *conn, team_id, fingerprint).await? + IssueFingerprintOverride::load(&mut *conn, team_id, &fingerprinted.fingerprint).await? { - return Ok(issue_override); + return Ok(fingerprinted.to_output(issue_override.issue_id)); } + // UNWRAP: We never resolve an issue for an exception with no exception list + let first = fingerprinted.exception_list.first().unwrap(); + let new_name = first.exception_type.clone(); + let new_description = first.exception_message.clone(); + // Start a transaction, so we can roll it back on override insert failure conn.begin().await?; // Insert a new issue - let issue = Issue::new(team_id); + let issue = Issue::new(team_id, new_name, new_description); // We don't actually care if we insert the issue here or not - conflicts aren't possible at // this stage. issue.insert(&mut *conn).await?; // Insert the fingerprint override - let issue_override = - IssueFingerprintOverride::create_or_load(&mut *conn, team_id, fingerprint, &issue).await?; + let issue_override = IssueFingerprintOverride::create_or_load( + &mut *conn, + team_id, + &fingerprinted.fingerprint, + &issue, + ) + .await?; // If we actually inserted a new row for the issue override, commit the transaction, // saving both the issue and the override. Otherwise, rollback the transaction, and @@ -160,7 +179,8 @@ where conn.rollback().await?; } else { conn.commit().await?; + // TODO - emit new issue and override to kafka } - Ok(issue_override) + Ok(fingerprinted.to_output(issue_override.issue_id)) } diff --git a/rust/cymbal/src/lib.rs b/rust/cymbal/src/lib.rs index b88634c1828cd..35386be8cca6a 100644 --- a/rust/cymbal/src/lib.rs +++ b/rust/cymbal/src/lib.rs @@ -6,8 +6,7 @@ use error::{EventError, UnhandledError}; use fingerprinting::generate_fingerprint; use issue_resolution::resolve_issue; use tracing::warn; -use types::{ErrProps, Exception, Stacktrace}; -use uuid::Uuid; +use types::{Exception, RawErrProps, Stacktrace}; pub mod app_context; pub mod config; @@ -33,16 +32,13 @@ pub async fn handle_event( } }; - let exceptions = match take_exception_list(event.uuid, &mut props) { - Ok(r) => r, - Err(e) => { - warn!("Failed to take exception list: {}", e); - // Add an error message, and patch the event properties back up. - props.add_error_message(format!("Failed to take exception list: {}", e)); - event.properties = Some(serde_json::to_string(&props).unwrap()); - return Ok(Some(event)); - } - }; + let exceptions = std::mem::take(&mut props.exception_list); + + if exceptions.is_empty() { + props.add_error_message("No exceptions found on exception event"); + event.properties = Some(serde_json::to_string(&props).unwrap()); + return Ok(Some(event)); + } let mut results = Vec::new(); for exception in exceptions.into_iter() { @@ -53,19 +49,17 @@ pub async fn handle_event( } let fingerprint = generate_fingerprint(&results); + props.exception_list = results; + let fingerprinted = props.to_fingerprinted(fingerprint.clone()); - let issue_override = resolve_issue(&context.pool, &fingerprint, event.team_id).await?; + let output = resolve_issue(&context.pool, event.team_id, fingerprinted).await?; - props.fingerprint = Some(fingerprint); - props.resolved_issue_id = Some(issue_override.issue_id); - props.exception_list = Some(results); - - event.properties = Some(serde_json::to_string(&props).unwrap()); + event.properties = Some(serde_json::to_string(&output).unwrap()); Ok(Some(event)) } -fn get_props(event: &ClickHouseEvent) -> Result { +fn get_props(event: &ClickHouseEvent) -> Result { if event.event != "$exception" { return Err(EventError::WrongEventType(event.event.clone(), event.uuid)); } @@ -74,7 +68,7 @@ fn get_props(event: &ClickHouseEvent) -> Result { return Err(EventError::NoProperties(event.uuid)); }; - let properties: ErrProps = match serde_json::from_str(properties) { + let properties: RawErrProps = match serde_json::from_str(properties) { Ok(r) => r, Err(e) => { return Err(EventError::InvalidProperties(event.uuid, e.to_string())); @@ -84,18 +78,6 @@ fn get_props(event: &ClickHouseEvent) -> Result { Ok(properties) } -fn take_exception_list(event_id: Uuid, props: &mut ErrProps) -> Result, EventError> { - let Some(exception_list) = props.exception_list.as_mut() else { - return Err(EventError::NoExceptionList(event_id)); - }; - - if exception_list.is_empty() { - return Err(EventError::EmptyExceptionList(event_id)); - } - - Ok(std::mem::take(exception_list)) -} - async fn process_exception( context: &AppContext, team_id: i32, diff --git a/rust/cymbal/src/types/mod.rs b/rust/cymbal/src/types/mod.rs index 3084297df89c1..23981cc29f861 100644 --- a/rust/cymbal/src/types/mod.rs +++ b/rust/cymbal/src/types/mod.rs @@ -46,24 +46,33 @@ pub struct Exception { // of only a small subset. This struct is used to give us a strongly-typed // "view" of those event properties we care about. #[derive(Debug, Deserialize, Serialize, Clone)] -pub struct ErrProps { +pub struct RawErrProps { #[serde(rename = "$exception_list")] - pub exception_list: Option>, // Required from exception producers - we will not process events without this. Optional to support older clients, should eventually be removed - #[serde( - rename = "$exception_fingerprint", - skip_serializing_if = "Option::is_none" - )] - pub fingerprint: Option, // We expect this not to exist when the event is received, and we populate it as part of processing - #[serde( - rename = "$exception_issue_id", - skip_serializing_if = "Option::is_none" - )] - pub resolved_issue_id: Option, // We populate the exception issue id as part of processing + pub exception_list: Vec, #[serde(flatten)] // A catch-all for all the properties we don't "care" about, so when we send back to kafka we don't lose any info pub other: HashMap, } +pub struct FingerprintedErrProps { + pub exception_list: Vec, + pub fingerprint: String, + pub other: HashMap, +} + +// We emit this +#[derive(Debug, Serialize, Clone)] +pub struct OutputErrProps { + #[serde(rename = "$exception_list")] + pub exception_list: Vec, + #[serde(rename = "$exception_fingerprint")] + pub fingerprint: String, + #[serde(rename = "$exception_issue_id")] + pub issue_id: Uuid, + #[serde(flatten)] + pub other: HashMap, +} + impl Exception { pub fn include_in_fingerprint(&self, h: &mut Sha512) { h.update(self.exception_type.as_bytes()); @@ -92,7 +101,7 @@ impl Exception { } } -impl ErrProps { +impl RawErrProps { pub fn add_error_message(&mut self, msg: impl ToString) { let mut errors = match self.other.remove("$cymbal_errors") { Some(serde_json::Value::Array(errors)) => errors, @@ -106,6 +115,25 @@ impl ErrProps { serde_json::Value::Array(errors), ); } + + pub fn to_fingerprinted(self, fingerprint: String) -> FingerprintedErrProps { + FingerprintedErrProps { + exception_list: self.exception_list, + fingerprint, + other: self.other, + } + } +} + +impl FingerprintedErrProps { + pub fn to_output(self, issue_id: Uuid) -> OutputErrProps { + OutputErrProps { + exception_list: self.exception_list, + fingerprint: self.fingerprint, + issue_id, + other: self.other, + } + } } #[cfg(test)] @@ -115,7 +143,7 @@ mod test { use crate::{frames::RawFrame, types::Stacktrace}; - use super::ErrProps; + use super::RawErrProps; #[test] fn it_deserialises_error_props() { @@ -123,8 +151,8 @@ mod test { let raw: ClickHouseEvent = serde_json::from_str(raw).unwrap(); - let props: ErrProps = serde_json::from_str(&raw.properties.unwrap()).unwrap(); - let exception_list = &props.exception_list.unwrap(); + let props: RawErrProps = serde_json::from_str(&raw.properties.unwrap()).unwrap(); + let exception_list = &props.exception_list; assert_eq!(exception_list.len(), 1); assert_eq!( @@ -173,9 +201,9 @@ mod test { "$exception_list": [] }"#; - let props: Result = serde_json::from_str(raw); + let props: Result = serde_json::from_str(raw); assert!(props.is_ok()); - assert_eq!(props.unwrap().exception_list.unwrap().len(), 0); + assert_eq!(props.unwrap().exception_list.len(), 0); let raw: &'static str = r#"{ "$exception_list": [{ @@ -183,7 +211,7 @@ mod test { }] }"#; - let props: Result = serde_json::from_str(raw); + let props: Result = serde_json::from_str(raw); assert!(props.is_err()); assert_eq!( props.unwrap_err().to_string(), @@ -197,7 +225,7 @@ mod test { }] }"#; - let props: Result = serde_json::from_str(raw); + let props: Result = serde_json::from_str(raw); assert!(props.is_err()); assert_eq!( props.unwrap_err().to_string(), diff --git a/rust/cymbal/tests/resolve.rs b/rust/cymbal/tests/resolve.rs index d92eac660615a..31533c3f297aa 100644 --- a/rust/cymbal/tests/resolve.rs +++ b/rust/cymbal/tests/resolve.rs @@ -9,7 +9,7 @@ use cymbal::{ sourcemap::SourcemapProvider, Catalog, }, - types::{ErrProps, Stacktrace}, + types::{RawErrProps, Stacktrace}, }; use httpmock::MockServer; use tokio::sync::Mutex; @@ -35,10 +35,10 @@ async fn end_to_end_resolver_test() { }); let exception: ClickHouseEvent = serde_json::from_str(EXAMPLE_EXCEPTION).unwrap(); - let props: ErrProps = serde_json::from_str(&exception.properties.unwrap()).unwrap(); + let mut props: RawErrProps = serde_json::from_str(&exception.properties.unwrap()).unwrap(); let Stacktrace::Raw { frames: mut test_stack, - } = props.exception_list.unwrap().swap_remove(0).stack.unwrap() + } = props.exception_list.swap_remove(0).stack.unwrap() else { panic!("Expected a Raw stacktrace") }; diff --git a/rust/cymbal/tests/types.rs b/rust/cymbal/tests/types.rs index 145a7606dcc1b..0404398a2b66b 100644 --- a/rust/cymbal/tests/types.rs +++ b/rust/cymbal/tests/types.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use common_types::ClickHouseEvent; -use cymbal::types::ErrProps; +use cymbal::types::RawErrProps; use serde_json::Value; #[test] @@ -11,7 +11,7 @@ fn serde_passthrough() { let raw: ClickHouseEvent = serde_json::from_str(raw).unwrap(); let before_properties: Value = serde_json::from_str(raw.properties.as_ref().unwrap()).unwrap(); - let properties_parsed: ErrProps = + let properties_parsed: RawErrProps = serde_json::from_str(raw.properties.as_ref().unwrap()).unwrap(); let properties_raw = serde_json::to_string(&properties_parsed).unwrap();