Skip to content

chore(dashboards): Discover split for self hosted dashboard discover widgets #92135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

nikkikapadia
Copy link
Member

The discover split for dashboards has been done for all users except self-hosted users. This migration converts all Discover widget types to either Transaction or Error using the _get_and_save_split_decision_for_dashboard_widget function. This function will try to appropriately categorize a widget query as Transaction or Error and will default to Error if a decision cannot be made. This uses the same logic of the original discover split job.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 22, 2025
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #92135      +/-   ##
==========================================
- Coverage   87.93%   87.89%   -0.04%     
==========================================
  Files       10174    10191      +17     
  Lines      583385   583680     +295     
  Branches    22596    22606      +10     
==========================================
+ Hits       512992   513042      +50     
- Misses      69941    70186     +245     
  Partials      452      452              

Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0912_split_discover_dataset_dashboards_self_hosted.py

for 0912_split_discover_dataset_dashboards_self_hosted in sentry

--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL

) -> None:
DashboardWidgetQuery = apps.get_model("sentry", "DashboardWidgetQuery")
catch_all_unsplit_widgets = Q(
widget__widget_type=DashboardWidgetTypes.DISCOVER,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's copy over all the enums into the migration file- it's a good practice to not reference application code in the migration. In case someone changes the enums in the application code, we know it's not going to break the migration if it's copied over here

Comment on lines 46 to 49
queryset = DashboardWidgetQuery.objects.filter(
widget__widget_type=DashboardWidgetTypes.ERROR_EVENTS,
widget__dataset_source=DatasetSourcesTypes.UNKNOWN.value,
).select_related("widget__dashboard__organization")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the select related here. Also, this revert is missing transaction widgets:

    queryset = DashboardWidgetQuery.objects.filter(
        widget__discover_widget_split__in=[DashboardWidgetTypes.ERROR_EVENTS, DashboardWidgetTypes.TRANSACTION_LIKE],
    )

try:
_get_and_save_split_decision_for_dashboard_widget(widget_query, dry_run=False)
except Exception:
widget_query.widget.widget_type = DashboardWidgetTypes.ERROR_EVENTS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_get_and_save_split_decision_for_dashboard_widget only updates discover_widget_split and dataset_source, so that's what we should do here also. Let's not update widget_type here.

Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0913_split_discover_dataset_dashboards_self_hosted.py

for 0913_split_discover_dataset_dashboards_self_hosted in sentry

--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants