File tree 2 files changed +28
-3
lines changed
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change
1
+ from typing import List , TypedDict
2
+
1
3
from django .conf import settings
2
4
from urllib3 import Retry
3
5
4
6
from sentry .net .http import connection_from_url
5
7
from sentry .utils import json
6
8
9
+
10
+ class BreakpointData (TypedDict ):
11
+ project : str
12
+ # For legacy reasons, the group name is always
13
+ # transaction even when working with functions.
14
+ transaction : str
15
+ aggregate_range_1 : float
16
+ aggregate_range_2 : float
17
+ unweighted_t_value : float
18
+ unweighted_p_value : float
19
+ trend_percentage : float
20
+ absolute_percentage_change : float
21
+ trend_difference : float
22
+ breakpoint : int
23
+
24
+
25
+ class BreakpointResponse (TypedDict ):
26
+ data : List [BreakpointData ]
27
+
28
+
7
29
seer_connection_pool = connection_from_url (
8
30
settings .ANOMALY_DETECTION_URL ,
9
31
retries = Retry (
14
36
)
15
37
16
38
17
- def detect_breakpoints (breakpoint_request ):
39
+ def detect_breakpoints (breakpoint_request ) -> BreakpointResponse :
18
40
response = seer_connection_pool .urlopen (
19
41
"POST" ,
20
42
"/trends/breakpoint-detector" ,
Original file line number Diff line number Diff line change 29
29
from sentry .search .events .builder import ProfileTopFunctionsTimeseriesQueryBuilder
30
30
from sentry .search .events .fields import get_function_alias
31
31
from sentry .search .events .types import QueryBuilderConfig
32
- from sentry .seer .utils import detect_breakpoints
32
+ from sentry .seer .utils import BreakpointData , detect_breakpoints
33
33
from sentry .sentry_metrics import indexer
34
34
from sentry .sentry_metrics .use_case_id_registry import UseCaseID
35
35
from sentry .snuba import functions
@@ -249,7 +249,10 @@ def _detect_function_trends(
249
249
)
250
250
251
251
252
- def _detect_function_change_points (functions_list : List [Tuple [int , int ]], start : datetime ) -> None :
252
+ def _detect_function_change_points (
253
+ functions_list : List [Tuple [int , int ]],
254
+ start : datetime ,
255
+ ) -> Generator [BreakpointData , None , None ]:
253
256
serializer = SnubaTSResultSerializer (None , None , None )
254
257
255
258
trend_function = "p95()"
You can’t perform that action at this time.
0 commit comments