Browse Source

Revert "du(chore): Remove performance issues options (#42466)"

This reverts commit d52f5fabeab331b5b661edd69e7bfc3b047f3e22.

Co-authored-by: udameli <23648387+udameli@users.noreply.github.com>
getsentry-bot 2 years ago
parent
commit
6adcf35f2c

+ 7 - 1
src/sentry/api/endpoints/organization_events_spans_count_histogram.py

@@ -3,6 +3,7 @@ from rest_framework import serializers
 from rest_framework.request import Request
 from rest_framework.response import Response
 
+from sentry import features
 from sentry.api.base import region_silo_endpoint
 from sentry.api.bases import NoProjects, OrganizationEventsV2EndpointBase
 from sentry.snuba import discover
@@ -30,12 +31,17 @@ class SpansCountHistogramSerializer(serializers.Serializer):
         return spanOp
 
 
-# TODO(udameli): Remove the endpoint because it will not be used
 @region_silo_endpoint
 class OrganizationEventsSpansCountHistogramEndpoint(OrganizationEventsV2EndpointBase):
     private = True
 
+    def has_feature(self, organization, request):
+        return features.has("organizations:performance-issues", organization, actor=request.user)
+
     def get(self, request: Request, organization) -> Response:
+        if not self.has_feature(organization, request):
+            return Response(status=404)
+
         try:
             params = self.get_snuba_params(request, organization)
         except NoProjects:

+ 5 - 2
src/sentry/api/endpoints/project_event_details.py

@@ -5,7 +5,7 @@ from typing import Any, List
 from rest_framework.request import Request
 from rest_framework.response import Response
 
-from sentry import eventstore
+from sentry import eventstore, features
 from sentry.api.base import region_silo_endpoint
 from sentry.api.bases.project import ProjectEndpoint
 from sentry.api.serializers import DetailedEventSerializer, serialize
@@ -22,7 +22,10 @@ def wrap_event_response(request_user: Any, event: Event, project: Project, envir
     prev_event_id = None
 
     if event.group_id:
-        if event.get_event_type() == "transaction":
+        if (
+            features.has("organizations:performance-issues", project.organization)
+            and event.get_event_type() == "transaction"
+        ):
             conditions = apply_performance_conditions([], event.group)
             _filter = eventstore.Filter(
                 conditions=conditions,

+ 2 - 0
src/sentry/api/endpoints/project_performance_issue_settings.py

@@ -27,6 +27,8 @@ class ProjectPerformanceIssueSettingsEndpoint(ProjectEndpoint):
     def has_feature(self, project, request) -> bool:
         return features.has(
             "organizations:performance-view", project.organization, actor=request.user
+        ) and features.has(
+            "organizations:performance-issues", project.organization, actor=request.user
         )
 
     def get(self, request: Request, project) -> Response:

+ 5 - 1
src/sentry/api/endpoints/project_rules_configuration.py

@@ -23,6 +23,7 @@ class ProjectRulesConfigurationEndpoint(ProjectEndpoint):
         can_create_tickets = features.has(
             "organizations:integrations-ticket-rules", project.organization
         )
+        perf_issue_filters = features.has("organizations:performance-issues", project.organization)
 
         # TODO: conditions need to be based on actions
         for rule_type, rule_cls in rules:
@@ -68,7 +69,10 @@ class ProjectRulesConfigurationEndpoint(ProjectEndpoint):
                 ):
                     condition_list.append(context)
             elif rule_type.startswith("filter/"):
-                filter_list.append(context)
+                if perf_issue_filters or context["id"] not in {
+                    "sentry.rules.filters.issue_category.IssueCategoryFilter",
+                }:
+                    filter_list.append(context)
             elif rule_type.startswith("action/"):
                 action_list.append(context)
 

+ 18 - 14
src/sentry/api/issue_search.py

@@ -143,13 +143,15 @@ def convert_category_value(
     environments: Optional[Sequence[Environment]],
 ) -> List[int]:
     """Convert a value like 'error' or 'performance' to the GroupType value for issue lookup"""
-    results = []
-    for category in value:
-        group_category = getattr(GroupCategory, category.upper(), None)
-        if not group_category:
-            raise InvalidSearchQuery(f"Invalid category value of '{category}'")
-        results.extend([type.value for type in GROUP_CATEGORY_TO_TYPES.get(group_category, [])])
-    return results
+    if features.has("organizations:performance-issues", projects[0].organization):
+        results = []
+        for category in value:
+            group_category = getattr(GroupCategory, category.upper(), None)
+            if not group_category:
+                raise InvalidSearchQuery(f"Invalid category value of '{category}'")
+            results.extend([type.value for type in GROUP_CATEGORY_TO_TYPES.get(group_category, [])])
+        return results
+    return []
 
 
 def convert_type_value(
@@ -159,13 +161,15 @@ def convert_type_value(
     environments: Optional[Sequence[Environment]],
 ) -> List[int]:
     """Convert a value like 'error' or 'performance_n_plus_one_db_queries' to the GroupType value for issue lookup"""
-    results = []
-    for type in value:
-        group_type = getattr(GroupType, type.upper(), None)
-        if not group_type:
-            raise InvalidSearchQuery(f"Invalid type value of '{type}'")
-        results.append(group_type.value)
-    return results
+    if features.has("organizations:performance-issues", projects[0].organization):
+        results = []
+        for type in value:
+            group_type = getattr(GroupType, type.upper(), None)
+            if not group_type:
+                raise InvalidSearchQuery(f"Invalid type value of '{type}'")
+            results.append(group_type.value)
+        return results
+    return []
 
 
 value_converters: Mapping[str, ValueConverter] = {

+ 6 - 0
src/sentry/conf/server.py

@@ -1137,6 +1137,8 @@ SENTRY_FEATURES = {
     "organizations:performance-mep-reintroduce-histograms": False,
     # Enable showing INP web vital in default views
     "organizations:performance-vitals-inp": False,
+    # Enable processing transactions in post_process_group
+    "organizations:performance-issues-post-process-group": False,
     # Enable internal view for bannerless MEP view
     "organizations:performance-mep-bannerless-ui": False,
     # Enable updated landing page widget designs
@@ -1163,6 +1165,10 @@ SENTRY_FEATURES = {
     "organizations:notification-all-recipients": False,
     # Enable the new native stack trace design
     "organizations:native-stack-trace-v2": False,
+    # Enable performance issues
+    "organizations:performance-issues": False,
+    # Enable the creation of performance issues in the ingest pipeline. Turning this on will eventually make performance issues be created with default settings.
+    "organizations:performance-issues-ingest": False,
     # Enable performance issues dev options, includes changing detection thresholds and other parts of issues that we're using for development.
     "organizations:performance-issues-dev": False,
     # Enables updated all events tab in a performance issue

+ 7 - 2
src/sentry/event_manager.py

@@ -2267,9 +2267,14 @@ def _save_aggregate_performance(jobs: Sequence[PerformanceJob], projects: Projec
         event = job["event"]
         project = event.project
 
-        # Granular, per-project option
+        if not features.has("organizations:performance-issues-ingest", project.organization):
+            continue
+        # General system-wide option
+        rate = options.get("performance.issues.all.problem-creation") or 0
+
+        # More granular, per-project option
         per_project_rate = project.get_option("sentry:performance_issue_creation_rate", 1.0)
-        if per_project_rate > random.random():
+        if rate > random.random() and per_project_rate > random.random():
 
             kwargs = _create_kwargs(job)
             kwargs["culprit"] = job["culprit"]

+ 5 - 1
src/sentry/eventstore/snuba/backend.py

@@ -6,9 +6,11 @@ from datetime import datetime, timedelta
 import sentry_sdk
 from django.utils import timezone
 
+from sentry import features
 from sentry.eventstore.base import EventStorage
 from sentry.eventstore.models import Event
 from sentry.models.group import Group
+from sentry.models.organization import Organization
 from sentry.snuba.dataset import Dataset
 from sentry.snuba.events import Columns
 from sentry.utils import snuba
@@ -200,7 +202,9 @@ class SnubaEventStorage(EventStorage):
             # Set passed group_id if not a transaction
             if event.get_event_type() == "transaction":
                 logger.warning("eventstore.passed-group-id-for-transaction")
-                return event.for_group(Group.objects.get(id=group_id))
+                org = Organization.objects.get(project__id=project_id)
+                if features.has("organizations:performance-issues", org):
+                    return event.for_group(Group.objects.get(id=group_id))
             else:
                 event.group_id = group_id
 

+ 3 - 0
src/sentry/features/__init__.py

@@ -116,6 +116,9 @@ default_manager.add("organizations:org-subdomains", OrganizationFeature)
 default_manager.add("organizations:performance-anomaly-detection-ui", OrganizationFeature, True)
 default_manager.add("organizations:performance-chart-interpolation", OrganizationFeature, True)
 default_manager.add("organizations:performance-dry-run-mep", OrganizationFeature, True)
+default_manager.add("organizations:performance-issues", OrganizationFeature, True)
+default_manager.add("organizations:performance-issues-ingest", OrganizationFeature)
+default_manager.add("organizations:performance-issues-post-process-group", OrganizationFeature)
 default_manager.add("organizations:performance-issues-dev", OrganizationFeature, True)
 default_manager.add("organizations:performance-issues-all-events-tab", OrganizationFeature, True)
 default_manager.add("organizations:performance-onboarding-checklist", OrganizationFeature, True)

+ 2 - 1
src/sentry/issues/search.py

@@ -4,6 +4,7 @@ import functools
 from copy import deepcopy
 from typing import Any, Callable, Mapping, Optional, Protocol, Sequence, Set, TypedDict
 
+from sentry import features
 from sentry.api.event_search import SearchFilter, SearchKey, SearchValue
 from sentry.models import Environment, Organization
 from sentry.search.events.filter import convert_search_filter_to_snuba_query
@@ -138,7 +139,7 @@ def _query_params_for_perf(
     conditions: Sequence[Any],
 ) -> Optional[SnubaQueryParams]:
     organization = Organization.objects.filter(id=organization_id).first()
-    if organization:
+    if organization and features.has("organizations:performance-issues", organization):
         transaction_conditions = _updated_conditions(
             "event.type",
             "=",

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