15
15
maybe_check_seer_for_matching_grouphash ,
16
16
should_call_seer_for_grouping ,
17
17
)
18
+ from sentry .grouping .utils import hash_from_values
18
19
from sentry .grouping .variants import BaseVariant
19
20
from sentry .models .grouphash import GroupHash
20
21
from sentry .models .grouphashmetadata import GroupHashMetadata
@@ -65,14 +66,16 @@ def setUp(self) -> None:
65
66
self .stacktrace_string = get_stacktrace_string (
66
67
get_grouping_info_from_variants (self .variants )
67
68
)
69
+ self .event_grouphash = GroupHash (project_id = self .project .id , hash = "908415" )
68
70
69
71
def test_obeys_feature_enablement_check (self ) -> None :
70
72
for backfill_completed_option , expected_result in [(None , False ), (11211231 , True )]:
71
73
self .project .update_option (
72
74
"sentry:similarity_backfill_completed" , backfill_completed_option
73
75
)
74
76
assert (
75
- should_call_seer_for_grouping (self .event , self .variants ) is expected_result
77
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
78
+ is expected_result
76
79
), f"Case { backfill_completed_option } failed."
77
80
78
81
def test_obeys_content_filter (self ) -> None :
@@ -83,21 +86,30 @@ def test_obeys_content_filter(self) -> None:
83
86
"sentry.grouping.ingest.seer._event_content_is_seer_eligible" ,
84
87
return_value = content_eligibility ,
85
88
):
86
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
89
+ assert (
90
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
91
+ is expected_result
92
+ )
87
93
88
94
def test_obeys_global_seer_killswitch (self ) -> None :
89
95
self .project .update_option ("sentry:similarity_backfill_completed" , int (time ()))
90
96
91
97
for killswitch_enabled , expected_result in [(True , False ), (False , True )]:
92
98
with override_options ({"seer.global-killswitch.enabled" : killswitch_enabled }):
93
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
99
+ assert (
100
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
101
+ is expected_result
102
+ )
94
103
95
104
def test_obeys_similarity_service_killswitch (self ) -> None :
96
105
self .project .update_option ("sentry:similarity_backfill_completed" , int (time ()))
97
106
98
107
for killswitch_enabled , expected_result in [(True , False ), (False , True )]:
99
108
with override_options ({"seer.similarity-killswitch.enabled" : killswitch_enabled }):
100
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
109
+ assert (
110
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
111
+ is expected_result
112
+ )
101
113
102
114
def test_obeys_project_specific_killswitch (self ) -> None :
103
115
self .project .update_option ("sentry:similarity_backfill_completed" , int (time ()))
@@ -106,7 +118,10 @@ def test_obeys_project_specific_killswitch(self) -> None:
106
118
with override_options (
107
119
{"seer.similarity.grouping_killswitch_projects" : blocked_projects }
108
120
):
109
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
121
+ assert (
122
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
123
+ is expected_result
124
+ )
110
125
111
126
def test_obeys_global_ratelimit (self ) -> None :
112
127
self .project .update_option ("sentry:similarity_backfill_completed" , int (time ()))
@@ -118,7 +133,10 @@ def test_obeys_global_ratelimit(self) -> None:
118
133
is_enabled if key == "seer:similarity:global-limit" else False
119
134
),
120
135
):
121
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
136
+ assert (
137
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
138
+ is expected_result
139
+ )
122
140
123
141
def test_obeys_project_ratelimit (self ) -> None :
124
142
self .project .update_option ("sentry:similarity_backfill_completed" , int (time ()))
@@ -132,7 +150,10 @@ def test_obeys_project_ratelimit(self) -> None:
132
150
else False
133
151
),
134
152
):
135
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
153
+ assert (
154
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
155
+ is expected_result
156
+ )
136
157
137
158
def test_obeys_circuit_breaker (self ) -> None :
138
159
self .project .update_option ("sentry:similarity_backfill_completed" , int (time ()))
@@ -142,7 +163,10 @@ def test_obeys_circuit_breaker(self) -> None:
142
163
"sentry.grouping.ingest.seer.CircuitBreaker.should_allow_request" ,
143
164
return_value = request_allowed ,
144
165
):
145
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
166
+ assert (
167
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
168
+ is expected_result
169
+ )
146
170
147
171
@with_feature ({"organizations:grouping-hybrid-fingerprint-seer-usage" : True })
148
172
def test_obeys_custom_fingerprint_check_flag_on (self ) -> None :
@@ -180,9 +204,11 @@ def test_obeys_custom_fingerprint_check_flag_on(self) -> None:
180
204
(custom_fingerprint_event , False ),
181
205
(built_in_fingerprint_event , False ),
182
206
]:
183
-
207
+ grouphash = GroupHash (
208
+ project_id = self .project .id , hash = hash_from_values (event .data ["fingerprint" ])
209
+ )
184
210
assert (
185
- should_call_seer_for_grouping (event , event .get_grouping_variants ())
211
+ should_call_seer_for_grouping (event , event .get_grouping_variants (), grouphash )
186
212
is expected_result
187
213
), f'Case with fingerprint { event .data ["fingerprint" ]} failed.'
188
214
@@ -229,9 +255,11 @@ def test_obeys_customized_fingerprint_check_flag_off(self) -> None:
229
255
(custom_fingerprint_event , False ),
230
256
(built_in_fingerprint_event , False ),
231
257
]:
232
-
258
+ grouphash = GroupHash (
259
+ project_id = self .project .id , hash = hash_from_values (event .data ["fingerprint" ])
260
+ )
233
261
assert (
234
- should_call_seer_for_grouping (event , event .get_grouping_variants ())
262
+ should_call_seer_for_grouping (event , event .get_grouping_variants (), grouphash )
235
263
is expected_result
236
264
), f'Case with fingerprint { event .data ["fingerprint" ]} failed.'
237
265
@@ -243,7 +271,10 @@ def test_obeys_excessive_frame_check(self) -> None:
243
271
"sentry.grouping.ingest.seer._has_too_many_contributing_frames" ,
244
272
return_value = frame_check_result ,
245
273
):
246
- assert should_call_seer_for_grouping (self .event , self .variants ) is expected_result
274
+ assert (
275
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash )
276
+ is expected_result
277
+ )
247
278
248
279
@patch ("sentry.grouping.ingest.seer.record_did_call_seer_metric" )
249
280
def test_obeys_empty_stacktrace_string_check (
@@ -261,16 +292,24 @@ def test_obeys_empty_stacktrace_string_check(
261
292
},
262
293
)
263
294
empty_frame_variants = empty_frame_event .get_grouping_variants ()
295
+ empty_frame_grouphash = GroupHash (project_id = self .project .id , hash = "415908" )
264
296
empty_frame_stacktrace_string = get_stacktrace_string (
265
297
get_grouping_info_from_variants (empty_frame_variants )
266
298
)
267
299
268
300
assert self .stacktrace_string != ""
269
- assert should_call_seer_for_grouping (self .event , self .variants ) is True
301
+ assert (
302
+ should_call_seer_for_grouping (self .event , self .variants , self .event_grouphash ) is True
303
+ )
270
304
mock_record_did_call_seer .assert_not_called ()
271
305
272
306
assert empty_frame_stacktrace_string == ""
273
- assert should_call_seer_for_grouping (empty_frame_event , empty_frame_variants ) is False
307
+ assert (
308
+ should_call_seer_for_grouping (
309
+ empty_frame_event , empty_frame_variants , empty_frame_grouphash
310
+ )
311
+ is False
312
+ )
274
313
mock_record_did_call_seer .assert_any_call (
275
314
empty_frame_event , call_made = False , blocker = "empty-stacktrace-string"
276
315
)
0 commit comments