Skip to content

fix(metrics): Remove use_metrics_layer from query builder core#108755

Merged
wedamija merged 3 commits intomasterfrom
flag-burner/dead/use-metrics-layer-pr2
Feb 23, 2026
Merged

fix(metrics): Remove use_metrics_layer from query builder core#108755
wedamija merged 3 commits intomasterfrom
flag-burner/dead/use-metrics-layer-pr2

Conversation

@wedamija
Copy link
Member

Summary

Removes all metrics layer infrastructure from the query builder core:

  • Deleted MetricsLayerDatasetConfig (datasets/metrics_layer.py, 670 lines) — the entire dataset config class only used when use_metrics_layer=True
  • Removed from QueryBuilderConfig: use_metrics_layer and insights_metrics_override_metric_layer fields
  • Removed from MetricsQueryBuilder: use_metrics_layer property, is_unsupported_metrics_layer_query property, metrics_layer_functions list, _is_unsupported_metrics_layer_query_cache
  • Removed from MetricsFunction: snql_metric_layer field
  • Simplified conditionals: All if self.use_metrics_layer or self.use_on_demand: simplified to if self.use_on_demand:, removing dead elif self.use_metrics_layer: branches in run_query methods across MetricsQueryBuilder, TimeseriesMetricQueryBuilder, TopEventsMetricsQueryBuilder, and AlertMetricsQueryBuilder
  • Removed orphaned code: resolve_metrics_layer_percentile helper in function_aliases.py
  • Cleaned up: entity_subscription.py (removed insights_metrics_override_metric_layer=True kwarg), test file references

PR 2 of 3 — based on PR 1 (flag-burner/dead/use-metrics-layer-pr1). Follow-up PR 3 will remove the flag registration.

Net: -981 lines, +61 lines

Test plan

  • pre-commit run --files passes on all changed files
  • No remaining use_metrics_layer references in src/sentry/
  • CI passes

@wedamija wedamija requested review from a team as code owners February 20, 2026 21:28
@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Feb 20, 2026
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Base automatically changed from flag-burner/dead/use-metrics-layer-pr1 to master February 23, 2026 17:42
Remove all metrics layer infrastructure from the query builder:
- Delete `MetricsLayerDatasetConfig` (670 lines)
- Remove `use_metrics_layer` and `insights_metrics_override_metric_layer`
  from `QueryBuilderConfig`
- Remove `use_metrics_layer` property, `is_unsupported_metrics_layer_query`
  property, and `metrics_layer_functions` list from `MetricsQueryBuilder`
- Remove `snql_metric_layer` from `MetricsFunction`
- Simplify all conditionals that checked `use_metrics_layer` — keep only
  the `use_on_demand` paths where applicable
- Remove orphaned `resolve_metrics_layer_percentile` helper
- Clean up entity_subscription.py and test references

PR 2 of 3, depends on PR 1.
Remove the organizations:use-metrics-layer flag from temporary.py
since all code referencing it has been removed.
@wedamija wedamija merged commit e1ed578 into master Feb 23, 2026
102 checks passed
@wedamija wedamija deleted the flag-burner/dead/use-metrics-layer-pr2 branch February 23, 2026 18:18
wedamija added a commit that referenced this pull request Feb 23, 2026
Master already removed use_metrics_layer from the query builder in
#108755. Remove the references that were incorrectly preserved during
rebase conflict resolution. Also remove now-dead get_features method
and batch_features variable from events_meta endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mchen-sentry pushed a commit that referenced this pull request Feb 24, 2026
## Summary

Removes all metrics layer infrastructure from the query builder core:

- **Deleted** `MetricsLayerDatasetConfig` (`datasets/metrics_layer.py`,
670 lines) — the entire dataset config class only used when
`use_metrics_layer=True`
- **Removed from `QueryBuilderConfig`**: `use_metrics_layer` and
`insights_metrics_override_metric_layer` fields
- **Removed from `MetricsQueryBuilder`**: `use_metrics_layer` property,
`is_unsupported_metrics_layer_query` property, `metrics_layer_functions`
list, `_is_unsupported_metrics_layer_query_cache`
- **Removed from `MetricsFunction`**: `snql_metric_layer` field
- **Simplified conditionals**: All `if self.use_metrics_layer or
self.use_on_demand:` simplified to `if self.use_on_demand:`, removing
dead `elif self.use_metrics_layer:` branches in `run_query` methods
across `MetricsQueryBuilder`, `TimeseriesMetricQueryBuilder`,
`TopEventsMetricsQueryBuilder`, and `AlertMetricsQueryBuilder`
- **Removed orphaned code**: `resolve_metrics_layer_percentile` helper
in `function_aliases.py`
- **Cleaned up**: `entity_subscription.py` (removed
`insights_metrics_override_metric_layer=True` kwarg), test file
references

**PR 2 of 3** — based on PR 1
(`flag-burner/dead/use-metrics-layer-pr1`). Follow-up PR 3 will remove
the flag registration.

Net: **-981 lines**, +61 lines

## Test plan
- [x] `pre-commit run --files` passes on all changed files
- [x] No remaining `use_metrics_layer` references in `src/sentry/`
- [ ] CI passes

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
mrduncan added a commit that referenced this pull request Mar 7, 2026
Remove 10 entries for deleted files/dirs and update 11 entries for
files/dirs that were moved.

Removed (deleted from codebase):
- /src/sentry/search/events/datasets/metrics_layer.py (removed in #108755)
- /src/sentry/utils/relocation.py (removed in #101738)
- requirements*.txt (removed in #97627, uv migration)
- babel.config.* (removed in #93303, jest 30 migration)
- jest-balance.json (never existed as tracked file)
- /src/sentry/api/endpoints/user_social_identity* (removed in #77231)
- /src/sentry/tasks/check_new_issue_threshold_met.py (removed in #97894)
- /tests/sentry/tasks/test_backfill_seer_grouping_records.py (removed in #102364)
- /tests/sentry/tasks/test_check_new_issue_threshold_met.py (removed in #97894)
- /src/sentry/api/endpoints/check_am2_compatibility.py (removed in #104288)

Updated (moved to new locations):
- event_reprocessable.py → /src/sentry/issues/endpoints/ (#97900)
- organization_event_details.py → /src/sentry/issues/endpoints/ (#97428)
- /static/app/{components,views}/codecov/ → .../prevent/ (#97485)
- organizationoption.py → models/options/organization_option.py (#31615)
- projectoption.py → models/options/project_option.py (#31615)
- useroption.py → users/models/user_option.py (#76231)
- organization_projects_experiment.py → /src/sentry/core/endpoints/ (#97407)
- release_threshold*.py → release_thresholds/ directory (#57085)
- test_organization_projects_experiment.py → /tests/sentry/core/endpoints/ (#97407)
- test_scim*.py → /tests/sentry/core/endpoints/scim/ (core migration)
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants