|
@@ -19,7 +19,12 @@ from sentry.models.transaction_threshold import (
|
|
|
TransactionMetric,
|
|
|
)
|
|
|
from sentry.search.events import constants
|
|
|
-from sentry.testutils.cases import APITestCase, PerformanceIssueTestCase, SnubaTestCase
|
|
|
+from sentry.testutils.cases import (
|
|
|
+ APITestCase,
|
|
|
+ PerformanceIssueTestCase,
|
|
|
+ ProfilesSnubaTestCase,
|
|
|
+ SnubaTestCase,
|
|
|
+)
|
|
|
from sentry.testutils.helpers import parse_link_header
|
|
|
from sentry.testutils.helpers.datetime import before_now, freeze_time, iso_format
|
|
|
from sentry.testutils.silo import region_silo_test
|
|
@@ -5743,106 +5748,36 @@ class OrganizationEventsProfilesDatasetEndpointTest(OrganizationEventsEndpointTe
|
|
|
|
|
|
|
|
|
@region_silo_test
|
|
|
-class OrganizationEventsProfileFunctionsDatasetEndpointTest(OrganizationEventsEndpointTestBase):
|
|
|
- @mock.patch("sentry.search.events.builder.discover.raw_snql_query")
|
|
|
- def test_functions_dataset_simple(self, mock_snql_query):
|
|
|
- mock_snql_query.side_effect = [
|
|
|
- {
|
|
|
- "data": [
|
|
|
- {
|
|
|
- "function": "foo_fn",
|
|
|
- "transaction": "foo_tx",
|
|
|
- "is_application": 1,
|
|
|
- "project": "python",
|
|
|
- "release": "backend@1",
|
|
|
- "platform.name": "python",
|
|
|
- "package": "lib_foo",
|
|
|
- "environment": "development",
|
|
|
- "p50()": 34695708.0,
|
|
|
- "p75()": 45980969.0,
|
|
|
- "p95()": 92592143.6,
|
|
|
- "p99()": 103764495.12000002,
|
|
|
- "avg()": 51235123.0,
|
|
|
- "sum()": 951283182.0,
|
|
|
- "examples()": [
|
|
|
- "6919e4076b4a46bbaf1f3ef1f0666147",
|
|
|
- "b04bafc378ea421b83b8680fd1caea52",
|
|
|
- "ceac40e40a0c44adb7f7b1e07f02586f",
|
|
|
- "6919e4076b4a46bbaf1f3ef1f0666147",
|
|
|
- "68acd0a8bdea46a59ba23907152b1ce5",
|
|
|
- "8ad2946586694c1b83d817fab3bccbc1",
|
|
|
- ],
|
|
|
- "count()": 12,
|
|
|
- },
|
|
|
- ],
|
|
|
- "meta": [
|
|
|
- {
|
|
|
- "name": "function",
|
|
|
- "type": "String",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "transaction",
|
|
|
- "type": "String",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "is_application",
|
|
|
- "type": "UInt8",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "project",
|
|
|
- "type": "String",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "release",
|
|
|
- "type": "String",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "platform.name",
|
|
|
- "type": "String",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "package",
|
|
|
- "type": "String",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "environment",
|
|
|
- "type": "String",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "p50()",
|
|
|
- "type": "Float64",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "p75()",
|
|
|
- "type": "Float64",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "p95()",
|
|
|
- "type": "Float64",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "p99()",
|
|
|
- "type": "Float64",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "avg()",
|
|
|
- "type": "Float64",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "sum()",
|
|
|
- "type": "Float64",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "examples()",
|
|
|
- "type": "Array(String)",
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "count()",
|
|
|
- "type": "UInt64",
|
|
|
- },
|
|
|
- ],
|
|
|
- }
|
|
|
- ]
|
|
|
+class OrganizationEventsProfileFunctionsDatasetEndpointTest(
|
|
|
+ OrganizationEventsEndpointTestBase, ProfilesSnubaTestCase
|
|
|
+):
|
|
|
+ def test_functions_dataset_simple(self):
|
|
|
+ self.store_functions(
|
|
|
+ [
|
|
|
+ {
|
|
|
+ "self_times_ns": [100 for _ in range(100)],
|
|
|
+ "package": "foo",
|
|
|
+ "function": "bar",
|
|
|
+ "in_app": True,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ project=self.project,
|
|
|
+ timestamp=before_now(hours=3),
|
|
|
+ )
|
|
|
+ self.store_functions(
|
|
|
+ [
|
|
|
+ {
|
|
|
+ "self_times_ns": [150 for _ in range(100)],
|
|
|
+ "package": "foo",
|
|
|
+ "function": "bar",
|
|
|
+ "in_app": True,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ project=self.project,
|
|
|
+ timestamp=before_now(hours=1),
|
|
|
+ )
|
|
|
+
|
|
|
+ mid = before_now(hours=2)
|
|
|
|
|
|
fields = [
|
|
|
"transaction",
|
|
@@ -5861,14 +5796,20 @@ class OrganizationEventsProfileFunctionsDatasetEndpointTest(OrganizationEventsEn
|
|
|
"p99()",
|
|
|
"avg()",
|
|
|
"sum()",
|
|
|
+ f"percentile_before(function.duration, 0.95, {int(mid.timestamp())})",
|
|
|
+ f"percentile_after(function.duration, 0.95, {int(mid.timestamp())})",
|
|
|
+ f"percentile_delta(function.duration, 0.95, {int(mid.timestamp())})",
|
|
|
]
|
|
|
|
|
|
- query = {
|
|
|
- "field": fields,
|
|
|
- "project": [self.project.id],
|
|
|
- "dataset": "profileFunctions",
|
|
|
- }
|
|
|
- response = self.do_request(query, features={"organizations:profiling": True})
|
|
|
+ response = self.do_request(
|
|
|
+ {
|
|
|
+ "field": fields,
|
|
|
+ "statsPeriod": "4h",
|
|
|
+ "project": [self.project.id],
|
|
|
+ "dataset": "profileFunctions",
|
|
|
+ },
|
|
|
+ features={"organizations:profiling": True},
|
|
|
+ )
|
|
|
assert response.status_code == 200, response.content
|
|
|
|
|
|
# making sure the response keys are in the form we expect and not aliased
|
|
@@ -5895,6 +5836,9 @@ class OrganizationEventsProfileFunctionsDatasetEndpointTest(OrganizationEventsEn
|
|
|
"p99()": "nanosecond",
|
|
|
"avg()": "nanosecond",
|
|
|
"sum()": "nanosecond",
|
|
|
+ f"percentile_before(function.duration, 0.95, {int(mid.timestamp())})": "nanosecond",
|
|
|
+ f"percentile_after(function.duration, 0.95, {int(mid.timestamp())})": "nanosecond",
|
|
|
+ f"percentile_delta(function.duration, 0.95, {int(mid.timestamp())})": "nanosecond",
|
|
|
}
|
|
|
|
|
|
|