Skip to content

Commit 98846a9

Browse files
wedamijamchen-sentry
authored andcommitted
fix(metrics): Remove use-metrics-layer flag from endpoints and snuba signatures (#108752)
## Summary The `organizations:use-metrics-layer` feature flag is permanently disabled — it defaults to `False` everywhere and is not enabled for any organization via flagpole. This PR removes all references from: - **API endpoints**: `organization_events.py`, `organization_events_stats.py`, `organization_events_meta.py`, `organization_events_histogram.py`, `data_export.py` - **Snuba module function signatures**: All dataset modules (`discover.py`, `metrics_performance.py`, `metrics_enhanced_performance.py`, `spans_metrics.py`, `spans_indexed.py`, `functions.py`, `errors.py`, `transactions.py`, `profiles.py`, `issue_platform.py`, `entity_subscription.py`, `types.py`) - **Other**: `snuba/tasks.py` telemetry tag, `check_am2_compatibility.py` QueryBuilderConfig kwarg - **Dead test classes**: 4 `WithMetricLayer` test classes that only tested the disabled code path **PR 1 of 3** — follow-up PRs will: - PR2: Remove from the query builder core (`MetricsQueryBuilder`, `MetricsLayerDatasetConfig`, etc.) - PR3: Remove flag registration from `temporary.py` and flagpole config ## Test plan - [x] `pre-commit run --files` passes on all changed files - [ ] CI passes - [ ] Verify no remaining `use_metrics_layer` references in modified files via grep
1 parent 8b239e5 commit 98846a9

23 files changed

+8
-331
lines changed

src/sentry/api/endpoints/organization_events.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def get_features(self, organization: Organization, request: Request) -> Mapping[
111111
"organizations:performance-use-metrics",
112112
"organizations:profiling",
113113
"organizations:dynamic-sampling",
114-
"organizations:use-metrics-layer",
115114
"organizations:starfish-view",
116115
"organizations:on-demand-metrics-extraction",
117116
"organizations:on-demand-metrics-extraction-widgets",
@@ -274,7 +273,6 @@ def _data_fn(
274273
transform_alias_to_input_format=True,
275274
# Whether the flag is enabled or not, regardless of the referrer
276275
has_metrics=use_metrics,
277-
use_metrics_layer=batch_features.get("organizations:use-metrics-layer", False),
278276
on_demand_metrics_enabled=on_demand_metrics_enabled,
279277
on_demand_metrics_type=on_demand_metrics_type,
280278
fallback_to_transactions=True,

src/sentry/api/endpoints/organization_events_histogram.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ def get(self, request: Request, organization: Organization) -> Response:
6565
use_metrics = features.has(
6666
"organizations:performance-use-metrics", organization=organization, actor=request.user
6767
)
68-
use_metrics_layer = features.has(
69-
"organizations:use-metrics-layer", organization=organization, actor=request.user
70-
)
7168
dataset = self.get_dataset(request) if use_metrics else discover
7269
metrics_enhanced = dataset != discover
7370

@@ -89,7 +86,6 @@ def get(self, request: Request, organization: Organization) -> Response:
8986
max_value=data.get("max"),
9087
data_filter=data.get("dataFilter"),
9188
referrer="api.organization-events-histogram",
92-
use_metrics_layer=use_metrics_layer,
9389
)
9490

9591
return Response(results)

src/sentry/api/endpoints/organization_events_meta.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def get_features(self, organization: Organization, request: Request) -> dict[str
3939
"organizations:performance-use-metrics",
4040
"organizations:profiling",
4141
"organizations:dynamic-sampling",
42-
"organizations:use-metrics-layer",
4342
"organizations:starfish-view",
4443
]
4544
batch_features = features.batch_has(
@@ -102,7 +101,6 @@ def get(self, request: Request, organization: Organization) -> Response:
102101
query=request.query_params.get("query"),
103102
referrer=Referrer.API_ORGANIZATION_EVENTS_META.value,
104103
has_metrics=use_metrics,
105-
use_metrics_layer=batch_features.get("organizations:use-metrics-layer", False),
106104
# TODO: @athena - add query_source when all datasets support it
107105
# query_source=(
108106
# QuerySource.FRONTEND if is_frontend_request(request) else QuerySource.API

src/sentry/api/endpoints/organization_events_stats.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def get_features(
7070
"organizations:performance-use-metrics",
7171
"organizations:dashboards-mep",
7272
"organizations:mep-rollout-flag",
73-
"organizations:use-metrics-layer",
7473
"organizations:starfish-view",
7574
"organizations:on-demand-metrics-extraction",
7675
"organizations:on-demand-metrics-extraction-widgets",
@@ -219,7 +218,6 @@ def get(self, request: Request, organization: Organization) -> Response:
219218
metric_types = ",".join(metric_type_values)
220219
return Response({"detail": f"Metric type must be one of: {metric_types}"}, status=400)
221220

222-
force_metrics_layer = request.GET.get("forceMetricsLayer") == "true"
223221
use_rpc = dataset in RPC_DATASETS
224222
transform_alias_to_input_format = (
225223
request.GET.get("transformAliasToInputFormat") == "1" or use_rpc
@@ -343,11 +341,6 @@ def get_rpc_config():
343341
comparison_delta=comparison_delta,
344342
allow_metric_aggregates=allow_metric_aggregates,
345343
has_metrics=use_metrics,
346-
# We want to allow people to force use the new metrics layer in the query builder. We decided to go for
347-
# this approach so that we can have only a subset of parts of sentry that use the new metrics layer for
348-
# their queries since right now the metrics layer has not full feature parity with the query builder.
349-
use_metrics_layer=force_metrics_layer
350-
or batch_features.get("organizations:use-metrics-layer", False),
351344
on_demand_metrics_enabled=use_on_demand_metrics
352345
and (
353346
batch_features.get("organizations:on-demand-metrics-extraction", False)

src/sentry/data_export/endpoints/data_export.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def get_features(self, organization: Organization, request: Request) -> dict[str
252252
"organizations:performance-use-metrics",
253253
"organizations:profiling",
254254
"organizations:dynamic-sampling",
255-
"organizations:use-metrics-layer",
256255
"organizations:starfish-view",
257256
]
258257
batch_features = features.batch_has(

src/sentry/snuba/discover.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def query(
178178
transform_alias_to_input_format: bool = False,
179179
sample: float | None = None,
180180
has_metrics: bool = False,
181-
use_metrics_layer: bool = False,
182181
skip_tag_resolution: bool = False,
183182
extra_columns: list[Column] | None = None,
184183
on_demand_metrics_enabled: bool = False,
@@ -276,7 +275,6 @@ def timeseries_query(
276275
functions_acl: list[str] | None = None,
277276
allow_metric_aggregates: bool = False,
278277
has_metrics: bool = False,
279-
use_metrics_layer: bool = False,
280278
on_demand_metrics_enabled: bool = False,
281279
on_demand_metrics_type: MetricSpecType | None = None,
282280
dataset: Dataset = Dataset.Discover,
@@ -822,7 +820,6 @@ def spans_histogram_query(
822820
limit_by: list[str] | None = None,
823821
extra_condition: list[Condition] | None = None,
824822
normalize_results: bool = True,
825-
use_metrics_layer: bool = False,
826823
on_demand_metrics_enabled: bool = False,
827824
on_demand_metrics_type: MetricSpecType | None = None,
828825
query_source: QuerySource | None = None,
@@ -913,7 +910,6 @@ def histogram_query(
913910
histogram_rows: int | None = None,
914911
extra_conditions: list[Condition] | None = None,
915912
normalize_results: bool = True,
916-
use_metrics_layer: bool = False,
917913
on_demand_metrics_enabled: bool = False,
918914
on_demand_metrics_type: MetricSpecType | None = None,
919915
query_source: QuerySource | None = None,

src/sentry/snuba/entity_subscription.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ def __init__(
386386
)
387387
self.org_id = extra_fields["org_id"]
388388
self.time_window = time_window
389-
self.use_metrics_layer = False
390389

391390
self.on_demand_metrics_enabled = features.has(
392391
"organizations:on-demand-metrics-extraction",
@@ -418,15 +417,9 @@ def _get_use_case_id(self) -> UseCaseID:
418417
return UseCaseID.SESSIONS
419418

420419
def resolve_tag_key_if_needed(self, string: str) -> str:
421-
if self.use_metrics_layer:
422-
return string
423-
424420
return resolve_tag_key(self._get_use_case_id(), self.org_id, string)
425421

426422
def resolve_tag_values_if_needed(self, strings: Sequence[str]) -> Sequence[str | int]:
427-
if self.use_metrics_layer:
428-
return strings
429-
430423
return resolve_tag_values(self._get_use_case_id(), self.org_id, strings)
431424

432425
def build_query_builder(
@@ -456,7 +449,6 @@ def build_query_builder(
456449
time_range_window=self.time_window,
457450
config=QueryBuilderConfig(
458451
skip_time_conditions=True,
459-
use_metrics_layer=self.use_metrics_layer,
460452
on_demand_metrics_enabled=self.on_demand_metrics_enabled,
461453
on_demand_metrics_type=MetricSpecType.SIMPLE_QUERY,
462454
skip_field_validation_for_entity_subscription_deletion=skip_field_validation_for_entity_subscription_deletion,
@@ -546,17 +538,13 @@ def aggregate_query_results(
546538
return aggregated_results
547539

548540
def get_snql_extra_conditions(self) -> list[Condition]:
549-
# If we don't use the metrics layer we need to filter by metric here. The metrics layer does this automatically.
550-
if not self.use_metrics_layer:
551-
return [
552-
Condition(
553-
Column("metric_id"),
554-
Op.EQ,
555-
resolve(UseCaseID.SESSIONS, self.org_id, self.metric_key.value),
556-
)
557-
]
558-
559-
return []
541+
return [
542+
Condition(
543+
Column("metric_id"),
544+
Op.EQ,
545+
resolve(UseCaseID.SESSIONS, self.org_id, self.metric_key.value),
546+
)
547+
]
560548

561549

562550
class MetricsCountersEntitySubscription(BaseCrashRateMetricsEntitySubscription):

src/sentry/snuba/errors.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def query(
5656
transform_alias_to_input_format: bool = False,
5757
sample: float | None = None,
5858
has_metrics: bool = False,
59-
use_metrics_layer: bool = False,
6059
skip_tag_resolution: bool = False,
6160
extra_columns: list[Column] | None = None,
6261
on_demand_metrics_enabled: bool = False,
@@ -112,7 +111,6 @@ def timeseries_query(
112111
functions_acl: list[str] | None = None,
113112
allow_metric_aggregates=False,
114113
has_metrics=False,
115-
use_metrics_layer=False,
116114
on_demand_metrics_enabled=False,
117115
on_demand_metrics_type: MetricSpecType | None = None,
118116
query_source: QuerySource | None = None,

src/sentry/snuba/functions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def query(
3737
transform_alias_to_input_format: bool = False,
3838
has_metrics: bool = False,
3939
functions_acl: list[str] | None = None,
40-
use_metrics_layer: bool = False,
4140
on_demand_metrics_enabled: bool = False,
4241
on_demand_metrics_type: MetricSpecType | None = None,
4342
fallback_to_transactions=False,
@@ -87,7 +86,6 @@ def timeseries_query(
8786
functions_acl: list[str] | None = None,
8887
allow_metric_aggregates: bool = False,
8988
has_metrics: bool = False,
90-
use_metrics_layer: bool = False,
9189
on_demand_metrics_enabled: bool = False,
9290
on_demand_metrics_type: MetricSpecType | None = None,
9391
query_source: QuerySource | None = None,

src/sentry/snuba/issue_platform.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def query(
3333
transform_alias_to_input_format=False,
3434
sample=None,
3535
has_metrics=False,
36-
use_metrics_layer=False,
3736
skip_tag_resolution=False,
3837
on_demand_metrics_enabled=False,
3938
on_demand_metrics_type: MetricSpecType | None = None,
@@ -117,7 +116,6 @@ def timeseries_query(
117116
functions_acl: list[str] | None = None,
118117
allow_metric_aggregates=False,
119118
has_metrics=False,
120-
use_metrics_layer=False,
121119
on_demand_metrics_enabled=False,
122120
on_demand_metrics_type: MetricSpecType | None = None,
123121
query_source: QuerySource | None = None,

0 commit comments

Comments
 (0)