Browse Source

feat(dashboards): Add discover dataset split column (#65824)

This adds an additional column and extends the enums allowed in the
'widget_type' (dataset) column. Once we confirm all the data is correct
we can migrate the result of the discover_split column into the dataset
column and drop the ext ra column

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Kev 1 year ago
parent
commit
11628f45b1

+ 1 - 1
migrations_lockfile.txt

@@ -9,5 +9,5 @@ feedback: 0004_index_together
 hybridcloud: 0012_apitoken_increase_token_length
 nodestore: 0002_nodestore_no_dictfield
 replays: 0004_index_together
-sentry: 0655_apitoken_increase_token_length
+sentry: 0656_add_discover_dataset_split_dashboard
 social_auth: 0002_default_auto_field

+ 32 - 0
src/sentry/migrations/0656_add_discover_dataset_split_dashboard.py

@@ -0,0 +1,32 @@
+# Generated by Django 5.0.2 on 2024-02-26 21:06
+
+from django.db import migrations
+
+import sentry.db.models.fields.bounded
+from sentry.new_migrations.migrations import CheckedMigration
+
+
+class Migration(CheckedMigration):
+    # This flag is used to mark that a migration shouldn't be automatically run in production. For
+    # the most part, this should only be used for operations where it's safe to run the migration
+    # after your code has deployed. So this should not be used for most operations that alter the
+    # schema of a table.
+    # Here are some things that make sense to mark as dangerous:
+    # - Large data migrations. Typically we want these to be run manually by ops so that they can
+    #   be monitored and not block the deploy for a long period of time while they run.
+    # - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
+    #   have ops run this and not block the deploy. Note that while adding an index is a schema
+    #   change, it's completely safe to run the operation after the code has deployed.
+    is_dangerous = False
+
+    dependencies = [
+        ("sentry", "0655_apitoken_increase_token_length"),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name="dashboardwidget",
+            name="discover_widget_split",
+            field=sentry.db.models.fields.bounded.BoundedPositiveIntegerField(null=True),
+        ),
+    ]

+ 27 - 0
src/sentry/models/dashboard_widget.py

@@ -47,9 +47,21 @@ class TypesClass:
 
 class DashboardWidgetTypes(TypesClass):
     DISCOVER = 0
+    """
+    Old way of accessing error events and transaction events simultaneously @deprecated. Use ERROR_EVENTS or TRANSACTION_LIKE instead.
+    """
     ISSUE = 1
     RELEASE_HEALTH = 2
     METRICS = 3
+    ERROR_EVENTS = 100
+    """
+     Error side of the split from Discover.
+    """
+    TRANSACTION_LIKE = 101
+    """
+    This targets transaction-like data from the split from discover. Itt may either use 'Transactions' events or 'PerformanceMetrics' depending on on-demand, MEP metrics, etc.
+    """
+
     TYPES = [
         (DISCOVER, "discover"),
         (ISSUE, "issue"),
@@ -58,10 +70,22 @@ class DashboardWidgetTypes(TypesClass):
             "metrics",
         ),  # TODO(ddm): rename RELEASE to 'release', and METRICS to 'metrics'
         (METRICS, "custom-metrics"),
+        (ERROR_EVENTS, "error-events"),
+        (TRANSACTION_LIKE, "transaction-like"),
     ]
     TYPE_NAMES = [t[1] for t in TYPES]
 
 
+# TODO: Can eventually be replaced solely with TRANSACTION_MULTI once no more dashboards use Discover.
+TransactionWidgetType = [DashboardWidgetTypes.DISCOVER, DashboardWidgetTypes.TRANSACTION_LIKE]
+# TODO: Can be replaced once conditions are replaced at all callsite to split transaction and error behaviour, and once dashboard no longer have saved Discover dataset.
+DiscoverFullFallbackWidgetType = [
+    DashboardWidgetTypes.DISCOVER,
+    DashboardWidgetTypes.ERROR_EVENTS,
+    DashboardWidgetTypes.TRANSACTION_LIKE,
+]
+
+
 class DashboardWidgetDisplayTypes(TypesClass):
     LINE_CHART = 0
     AREA_CHART = 1
@@ -205,6 +229,9 @@ class DashboardWidget(Model):
     widget_type = BoundedPositiveIntegerField(choices=DashboardWidgetTypes.as_choices(), null=True)
     limit = models.IntegerField(null=True)
     detail: models.Field[dict[str, Any], dict[str, Any]] = JSONField(null=True)
+    discover_widget_split = BoundedPositiveIntegerField(
+        choices=DashboardWidgetTypes.as_choices(), null=True
+    )
 
     class Meta:
         app_label = "sentry"

File diff suppressed because it is too large
+ 204 - 204
tests/sentry/backup/snapshots/ReleaseTests/test_at_head.pysnap


Some files were not shown because too many files changed in this diff