|
@@ -4,6 +4,7 @@ from unittest import mock
|
|
|
from uuid import uuid4
|
|
|
|
|
|
from django.urls import reverse
|
|
|
+from snuba_sdk import Column, Condition, Function, Op
|
|
|
|
|
|
from sentry.api.endpoints.organization_spans_aggregation import NULL_GROUP
|
|
|
from sentry.testutils.cases import APITestCase, SnubaTestCase
|
|
@@ -250,6 +251,9 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
"span.group": "B",
|
|
|
"span.description": "connect",
|
|
|
},
|
|
|
+ "sentry_tags": {
|
|
|
+ "description": "connect",
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
"same_process_as_parent": True,
|
|
@@ -265,6 +269,9 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
"span.group": "C",
|
|
|
"span.description": "connect",
|
|
|
},
|
|
|
+ "sentry_tags": {
|
|
|
+ "description": "connect",
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
"same_process_as_parent": True,
|
|
@@ -280,6 +287,9 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
"span.group": "D",
|
|
|
"span.description": "resolve_orderby",
|
|
|
},
|
|
|
+ "sentry_tags": {
|
|
|
+ "description": "resolve_orderby",
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
"same_process_as_parent": True,
|
|
@@ -329,6 +339,9 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
"span.group": "B",
|
|
|
"span.description": "connect",
|
|
|
},
|
|
|
+ "sentry_tags": {
|
|
|
+ "description": "connect",
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
"same_process_as_parent": True,
|
|
@@ -344,6 +357,9 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
"span.group": "C",
|
|
|
"span.description": "connect",
|
|
|
},
|
|
|
+ "sentry_tags": {
|
|
|
+ "description": "connect",
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
"same_process_as_parent": True,
|
|
@@ -359,6 +375,9 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
"span.group": "D",
|
|
|
"span.description": "resolve_orderby",
|
|
|
},
|
|
|
+ "sentry_tags": {
|
|
|
+ "description": "resolve_orderby",
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
"same_process_as_parent": True,
|
|
@@ -374,6 +393,9 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
"span.group": "D",
|
|
|
"span.description": "resolve_orderby",
|
|
|
},
|
|
|
+ "sentry_tags": {
|
|
|
+ "description": "resolve_orderby",
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
"same_process_as_parent": True,
|
|
@@ -488,5 +510,54 @@ class OrganizationSpansAggregationTest(APITestCase, SnubaTestCase):
|
|
|
data = response.data
|
|
|
root_fingerprint = hashlib.md5(b"e238e6c2e2466b07-C-discover.snql").hexdigest()[:16]
|
|
|
assert root_fingerprint in data
|
|
|
- assert data[root_fingerprint]["description"] == "resolve_columns"
|
|
|
+ assert data[root_fingerprint]["description"] == ""
|
|
|
assert data[root_fingerprint]["count()"] == 2
|
|
|
+
|
|
|
+ @mock.patch("sentry.api.endpoints.organization_spans_aggregation.raw_snql_query")
|
|
|
+ def test_http_method_filter(self, mock_query):
|
|
|
+ with self.feature(self.FEATURES):
|
|
|
+ response = self.client.get(
|
|
|
+ self.url,
|
|
|
+ data={"transaction": "api/0/foo", "backend": "nodestore", "http.method": "GET"},
|
|
|
+ format="json",
|
|
|
+ )
|
|
|
+
|
|
|
+ assert response.data
|
|
|
+ data = response.data
|
|
|
+ root_fingerprint = hashlib.md5(b"e238e6c2e2466b07").hexdigest()[:16]
|
|
|
+ assert root_fingerprint in data
|
|
|
+ assert data[root_fingerprint]["count()"] == 2
|
|
|
+
|
|
|
+ with self.feature(self.FEATURES):
|
|
|
+ response = self.client.get(
|
|
|
+ self.url,
|
|
|
+ data={"transaction": "api/0/foo", "backend": "nodestore", "http.method": "POST"},
|
|
|
+ format="json",
|
|
|
+ )
|
|
|
+
|
|
|
+ assert response.data == {}
|
|
|
+
|
|
|
+ with self.feature(self.FEATURES):
|
|
|
+ self.client.get(
|
|
|
+ self.url,
|
|
|
+ data={"transaction": "api/0/foo", "backend": "indexedSpans", "http.method": "GET"},
|
|
|
+ format="json",
|
|
|
+ )
|
|
|
+
|
|
|
+ assert (
|
|
|
+ Condition(
|
|
|
+ lhs=Function(
|
|
|
+ function="ifNull",
|
|
|
+ parameters=[
|
|
|
+ Column(
|
|
|
+ name="tags[transaction.method]",
|
|
|
+ ),
|
|
|
+ "",
|
|
|
+ ],
|
|
|
+ alias=None,
|
|
|
+ ),
|
|
|
+ op=Op.EQ,
|
|
|
+ rhs="GET",
|
|
|
+ )
|
|
|
+ in mock_query.mock_calls[0].args[0].query.where
|
|
|
+ )
|