Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/sentry/api/endpoints/organization_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class OrganizationEventsEndpoint(OrganizationEventsEndpointBase):

def get_features(self, organization: Organization, request: Request) -> Mapping[str, bool]:
feature_names = [
"organizations:dashboards-mep",
"organizations:mep-rollout-flag",
"organizations:performance-use-metrics",
"organizations:profiling",
Expand Down Expand Up @@ -199,15 +198,6 @@ def get(self, request: Request, organization: Organization) -> Response:

batch_features = self.get_features(organization, request)

use_metrics = (
(
batch_features.get("organizations:mep-rollout-flag", False)
and batch_features.get("organizations:dynamic-sampling", False)
)
or batch_features.get("organizations:performance-use-metrics", False)
or batch_features.get("organizations:dashboards-mep", False)
)

try:
use_on_demand_metrics, on_demand_metrics_type = self.handle_on_demand(request)
except ValueError:
Expand Down Expand Up @@ -272,7 +262,7 @@ def _data_fn(
use_aggregate_conditions=use_aggregate_conditions,
transform_alias_to_input_format=True,
# Whether the flag is enabled or not, regardless of the referrer
has_metrics=use_metrics,
has_metrics=True,
on_demand_metrics_enabled=on_demand_metrics_enabled,
on_demand_metrics_type=on_demand_metrics_type,
fallback_to_transactions=True,
Expand Down
44 changes: 2 additions & 42 deletions src/sentry/api/endpoints/organization_events_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rest_framework.request import Request
from rest_framework.response import Response

from sentry import features, options, search
from sentry import options, search
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
from sentry.api.bases import NoProjects, OrganizationEventsEndpointBase
Expand All @@ -32,35 +32,6 @@ class OrganizationEventsMetaEndpoint(OrganizationEventsEndpointBase):
"GET": ApiPublishStatus.PRIVATE,
}

def get_features(self, organization: Organization, request: Request) -> dict[str, bool | None]:
feature_names = [
"organizations:dashboards-mep",
"organizations:mep-rollout-flag",
"organizations:performance-use-metrics",
"organizations:profiling",
"organizations:dynamic-sampling",
"organizations:starfish-view",
]
batch_features = features.batch_has(
feature_names,
organization=organization,
actor=request.user,
)

all_features = (
batch_features.get(f"organization:{organization.id}", {})
if batch_features is not None
else {}
)

for feature_name in feature_names:
if feature_name not in all_features:
all_features[feature_name] = features.has(
feature_name, organization=organization, actor=request.user
)

return all_features

def get(self, request: Request, organization: Organization) -> Response:
try:
snuba_params = self.get_snuba_params(request, organization)
Expand All @@ -69,17 +40,6 @@ def get(self, request: Request, organization: Organization) -> Response:

dataset = self.get_dataset(request)

batch_features = self.get_features(organization, request)

use_metrics = (
(
batch_features.get("organizations:mep-rollout-flag", False)
and batch_features.get("organizations:dynamic-sampling", False)
)
or batch_features.get("organizations:performance-use-metrics", False)
or batch_features.get("organizations:dashboards-mep", False)
)

with handle_query_errors():
if dataset in RPC_DATASETS:
result = dataset.run_table_query(
Expand All @@ -100,7 +60,7 @@ def get(self, request: Request, organization: Organization) -> Response:
snuba_params=snuba_params,
query=request.query_params.get("query"),
referrer=Referrer.API_ORGANIZATION_EVENTS_META.value,
has_metrics=use_metrics,
has_metrics=True,
# TODO: @athena - add query_source when all datasets support it
# query_source=(
# QuerySource.FRONTEND if is_frontend_request(request) else QuerySource.API
Expand Down
15 changes: 1 addition & 14 deletions src/sentry/api/endpoints/organization_events_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def get_features(
) -> Mapping[str, bool | None]:
feature_names = [
"organizations:performance-use-metrics",
"organizations:dashboards-mep",
"organizations:mep-rollout-flag",
"organizations:starfish-view",
"organizations:on-demand-metrics-extraction",
Expand Down Expand Up @@ -169,18 +168,6 @@ def get(self, request: Request, organization: Organization) -> Response:
query_source = QuerySource.SENTRY_BACKEND

batch_features = self.get_features(organization, request)
use_metrics = (
batch_features.get("organizations:performance-use-metrics", False)
or batch_features.get("organizations:dashboards-mep", False)
or (
batch_features.get("organizations:mep-rollout-flag", False)
and features.has(
"organizations:dynamic-sampling",
organization=organization,
actor=request.user,
)
)
)

dataset = self.get_dataset(request)
# Add more here until top events is supported on all the datasets
Expand Down Expand Up @@ -340,7 +327,7 @@ def get_rpc_config():
zerofill_results=zerofill_results,
comparison_delta=comparison_delta,
allow_metric_aggregates=allow_metric_aggregates,
has_metrics=use_metrics,
has_metrics=True,
on_demand_metrics_enabled=use_on_demand_metrics
and (
batch_features.get("organizations:on-demand-metrics-extraction", False)
Expand Down
43 changes: 2 additions & 41 deletions src/sentry/api/endpoints/organization_events_timeseries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections.abc import Mapping
from datetime import datetime, timedelta
from typing import Any

Expand All @@ -8,7 +7,7 @@
from rest_framework.request import Request
from rest_framework.response import Response

from sentry import analytics, features
from sentry import analytics
from sentry.analytics.events.agent_monitoring_events import AgentMonitoringQuery
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
Expand Down Expand Up @@ -99,30 +98,6 @@ class OrganizationEventsTimeseriesEndpoint(OrganizationEventsEndpointBase):
}
)

def get_features(
self, organization: Organization, request: Request
) -> Mapping[str, bool | None]:
feature_names = [
"organizations:performance-use-metrics",
"organizations:dashboards-mep",
"organizations:mep-rollout-flag",
]
batch_features = features.batch_has(
feature_names,
organization=organization,
actor=request.user,
)
return (
batch_features.get(f"organization:{organization.id}", {})
if batch_features is not None
else {
feature_name: features.has(
feature_name, organization=organization, actor=request.user
)
for feature_name in feature_names
}
)

def get_request_querysource(self, request: Request, referrer: str) -> QuerySource:
if referrer in SENTRY_BACKEND_REFERRERS:
return QuerySource.SENTRY_BACKEND
Expand Down Expand Up @@ -300,20 +275,6 @@ def get_event_stats(

self._emit_analytics_event(organization, referrer)

batch_features = self.get_features(organization, request)
use_metrics = (
batch_features.get("organizations:performance-use-metrics", False)
or batch_features.get("organizations:dashboards-mep", False)
or (
batch_features.get("organizations:mep-rollout-flag", False)
and features.has(
"organizations:dynamic-sampling",
organization=organization,
actor=request.user,
)
)
)

if top_events > 0:
raw_groupby = self.get_field_list(organization, request, param_name="groupBy")
raw_orderby = self.get_orderby(request)
Expand Down Expand Up @@ -379,7 +340,7 @@ def get_event_stats(
zerofill_results=True,
comparison_delta=comparison_delta,
allow_metric_aggregates=allow_metric_aggregates,
has_metrics=use_metrics,
has_metrics=True,
query_source=query_source,
fallback_to_transactions=True,
transform_alias_to_input_format=True,
Expand Down
42 changes: 1 addition & 41 deletions src/sentry/api/serializers/rest_framework/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
DashboardWidgetTypes,
DatasetSourcesTypes,
)
from sentry.models.organization import Organization
from sentry.models.team import Team
from sentry.relay.config.metric_extraction import get_current_widget_specs, widget_exceeds_max_specs
from sentry.search.events.builder.discover import UnresolvedQuery
Expand All @@ -43,7 +42,6 @@
set_or_create_on_demand_state,
)
from sentry.tasks.relay import schedule_invalidate_project_config
from sentry.users.models.user import User
from sentry.utils.dates import parse_stats_period
from sentry.utils.strings import oxfordize_list

Expand Down Expand Up @@ -182,33 +180,6 @@ class DashboardWidgetQuerySerializer(CamelSnakeSerializer[Dashboard]):

validate_id = validate_id

def get_metrics_features(
self, organization: Organization | None, user: User | None
) -> dict[str, bool | None]:
if organization is None or user is None:
return {}

feature_names = [
"organizations:mep-rollout-flag",
"organizations:dynamic-sampling",
"organizations:performance-use-metrics",
"organizations:dashboards-mep",
]
batch_features = features.batch_has(
feature_names,
organization=organization,
actor=user,
)

return (
batch_features.get(f"organization:{organization.id}", {})
if batch_features is not None
else {
feature_name: features.has(feature_name, organization=organization, actor=user)
for feature_name in feature_names
}
)

def validate(self, data):
if not data.get("id"):
keys = set(data.keys())
Expand Down Expand Up @@ -264,17 +235,6 @@ def validate(self, data):
data["issue_query_error"] = {"conditions": [f"Invalid conditions: {err}"]}

try:
batch_features = self.get_metrics_features(
self.context.get("organization"), self.context.get("user")
)
use_metrics = bool(
(
batch_features.get("organizations:mep-rollout-flag", False)
and batch_features.get("organizations:dynamic-sampling", False)
)
or batch_features.get("organizations:performance-use-metrics", False)
or batch_features.get("organizations:dashboards-mep", False)
)
# When using the eps/epm functions, they require an interval argument
# or to provide the start/end so that the interval can be computed.
# This uses a hard coded start/end to ensure the validation succeeds
Expand All @@ -293,7 +253,7 @@ def validate(self, data):
elif self.context.get("widget_type") == DashboardWidgetTypes.get_type_name(
DashboardWidgetTypes.TRANSACTION_LIKE
):
config.has_metrics = use_metrics
config.has_metrics = True
builder = UnresolvedQuery(
dataset=Dataset.Discover,
params=params,
Expand Down
42 changes: 1 addition & 41 deletions src/sentry/data_export/endpoints/data_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,35 +245,6 @@ class DataExportEndpoint(OrganizationEndpoint):
}
permission_classes = (OrganizationDataExportPermission,)

def get_features(self, organization: Organization, request: Request) -> dict[str, bool | None]:
feature_names = [
"organizations:dashboards-mep",
"organizations:mep-rollout-flag",
"organizations:performance-use-metrics",
"organizations:profiling",
"organizations:dynamic-sampling",
"organizations:starfish-view",
]
batch_features = features.batch_has(
feature_names,
organization=organization,
actor=request.user,
)

all_features = (
batch_features.get(f"organization:{organization.id}", {})
if batch_features is not None
else {}
)

for feature_name in feature_names:
if feature_name not in all_features:
all_features[feature_name] = features.has(
feature_name, organization=organization, actor=request.user
)

return all_features

def post(self, request: Request, organization: Organization) -> Response:
"""
Create a new asynchronous file export task, and
Expand Down Expand Up @@ -310,17 +281,6 @@ def post(self, request: Request, organization: Organization) -> Response:
if request.data and hasattr(request.data, "get"):
limit = request.data.get("limit")

batch_features = self.get_features(organization, request)

use_metrics = (
(
batch_features.get("organizations:mep-rollout-flag", False)
and batch_features.get("organizations:dynamic-sampling", False)
)
or batch_features.get("organizations:performance-use-metrics", False)
or batch_features.get("organizations:dashboards-mep", False)
)

# Validate the data export payload
serializer = DataExportQuerySerializer(
data=request.data,
Expand All @@ -330,7 +290,7 @@ def post(self, request: Request, organization: Organization) -> Response:
request=request, organization=organization, project_ids=project_query
),
"get_projects": lambda: self.get_projects(request, organization),
"has_metrics": use_metrics,
"has_metrics": True,
},
)
if not serializer.is_valid():
Expand Down
Loading
Loading