Browse Source

feat(snql): Enable snql on the events_vitals endpoint (#30552)

- This enables the snql on this endpoint as part of the
performance-use-snql feature flag
William Mak 3 years ago
parent
commit
a71e5b591b

+ 4 - 0
src/sentry/api/endpoints/organization_events_vitals.py

@@ -2,6 +2,7 @@ import sentry_sdk
 from rest_framework.exceptions import ParseError
 from rest_framework.response import Response
 
+from sentry import features
 from sentry.api.bases import NoProjects, OrganizationEventsV2EndpointBase
 from sentry.search.events.fields import get_function_alias
 from sentry.snuba import discover
@@ -56,6 +57,9 @@ class OrganizationEventsVitalsEndpoint(OrganizationEventsV2EndpointBase):
                 auto_fields=True,
                 auto_aggregations=False,
                 use_aggregate_conditions=False,
+                use_snql=features.has(
+                    "organizations:performance-use-snql", organization, actor=request.user
+                ),
             )
 
         results = {}

+ 8 - 0
tests/snuba/api/endpoints/test_organization_events_vitals.py

@@ -19,6 +19,7 @@ class OrganizationEventsVitalsEndpointTest(APITestCase, SnubaTestCase):
             "start": iso_format(self.start),
             "end": iso_format(self.end),
         }
+        self.features = {}
 
     def store_event(self, data, measurements=None, **kwargs):
         if measurements:
@@ -33,6 +34,7 @@ class OrganizationEventsVitalsEndpointTest(APITestCase, SnubaTestCase):
     def do_request(self, query=None, features=None):
         if features is None:
             features = {"organizations:discover-basic": True}
+        features.update(self.features)
         if query is None:
             query = self.query
 
@@ -254,3 +256,9 @@ class OrganizationEventsVitalsEndpointTest(APITestCase, SnubaTestCase):
             "total": 0,
             "p75": None,
         }
+
+
+class OrganizationEventsVitalsEndpointTestWithSnql(OrganizationEventsVitalsEndpointTest):
+    def setUp(self):
+        super().setUp()
+        self.features = {"organizations:performance-use-snql": True}