3
3
from typing import Any
4
4
5
5
from sentry .eventstore .models import Event
6
- from sentry .grouping .component import BaseGroupingComponent
6
+ from sentry .grouping .component import (
7
+ ChainedExceptionGroupingComponent ,
8
+ ContextLineGroupingComponent ,
9
+ ErrorTypeGroupingComponent ,
10
+ ErrorValueGroupingComponent ,
11
+ ExceptionGroupingComponent ,
12
+ FilenameGroupingComponent ,
13
+ FrameGroupingComponent ,
14
+ FunctionGroupingComponent ,
15
+ LineNumberGroupingComponent ,
16
+ ModuleGroupingComponent ,
17
+ SaltGroupingComponent ,
18
+ StacktraceGroupingComponent ,
19
+ SymbolGroupingComponent ,
20
+ ThreadsGroupingComponent ,
21
+ )
7
22
from sentry .grouping .strategies .base import (
8
23
GroupingContext ,
9
24
ReturnedVariants ,
@@ -164,17 +179,15 @@ def single_exception_legacy(
164
179
interface : SingleException , event : Event , context : GroupingContext , ** meta : Any
165
180
) -> ReturnedVariants :
166
181
167
- type_component = BaseGroupingComponent (
168
- id = "type" ,
182
+ type_component = ErrorTypeGroupingComponent (
169
183
values = [interface .type ] if interface .type else [],
170
184
contributes = False ,
171
185
)
172
- value_component = BaseGroupingComponent (
173
- id = "value" ,
186
+ value_component = ErrorValueGroupingComponent (
174
187
values = [interface .value ] if interface .value else [],
175
188
contributes = False ,
176
189
)
177
- stacktrace_component = BaseGroupingComponent ( id = "stacktrace" )
190
+ stacktrace_component = StacktraceGroupingComponent ( )
178
191
179
192
if interface .stacktrace is not None :
180
193
stacktrace_component = context .get_single_grouping_component (
@@ -195,8 +208,8 @@ def single_exception_legacy(
195
208
value_component .update (contributes = True )
196
209
197
210
return {
198
- context ["variant" ]: BaseGroupingComponent (
199
- id = "exception" , values = [stacktrace_component , type_component , value_component ]
211
+ context ["variant" ]: ExceptionGroupingComponent (
212
+ values = [stacktrace_component , type_component , value_component ]
200
213
)
201
214
}
202
215
@@ -231,7 +244,7 @@ def chained_exception_legacy(
231
244
if stacktrace_component is None or not stacktrace_component .contributes :
232
245
value .update (contributes = False , hint = "exception has no stacktrace" )
233
246
234
- return {context ["variant" ]: BaseGroupingComponent ( id = "chained-exception" , values = values )}
247
+ return {context ["variant" ]: ChainedExceptionGroupingComponent ( values = values )}
235
248
236
249
237
250
@chained_exception_legacy .variant_processor
@@ -262,7 +275,7 @@ def frame_legacy(
262
275
# Safari throws [native code] frames in for calls like ``forEach``
263
276
# whereas Chrome ignores these. Let's remove it from the hashing algo
264
277
# so that they're more likely to group together
265
- filename_component = BaseGroupingComponent ( id = "filename" )
278
+ filename_component = FilenameGroupingComponent ( )
266
279
if interface .filename == "<anonymous>" :
267
280
filename_component .update (
268
281
contributes = False , values = [interface .filename ], hint = "anonymous filename discarded"
@@ -293,13 +306,13 @@ def frame_legacy(
293
306
# if we have a module we use that for grouping. This will always
294
307
# take precedence over the filename, even if the module is
295
308
# considered unhashable.
296
- module_component = BaseGroupingComponent ( id = "module" )
309
+ module_component = ModuleGroupingComponent ( )
297
310
if interface .module :
298
311
if is_unhashable_module_legacy (interface , platform ):
299
312
module_component .update (
300
313
values = [
301
- BaseGroupingComponent (
302
- id = "salt" , values = ["<module>" ], hint = "normalized generated module name"
314
+ SaltGroupingComponent (
315
+ values = ["<module>" ], hint = "normalized generated module name"
303
316
)
304
317
],
305
318
hint = "ignored module" ,
@@ -313,7 +326,7 @@ def frame_legacy(
313
326
)
314
327
315
328
# Context line when available is the primary contributor
316
- context_line_component = BaseGroupingComponent ( id = "context-line" )
329
+ context_line_component = ContextLineGroupingComponent ( )
317
330
if interface .context_line is not None :
318
331
if len (interface .context_line ) > 120 :
319
332
context_line_component .update (hint = "discarded because line too long" )
@@ -322,9 +335,9 @@ def frame_legacy(
322
335
else :
323
336
context_line_component .update (values = [interface .context_line ])
324
337
325
- symbol_component = BaseGroupingComponent ( id = "symbol" )
326
- function_component = BaseGroupingComponent ( id = "function" )
327
- lineno_component = BaseGroupingComponent ( id = "lineno" )
338
+ symbol_component = SymbolGroupingComponent ( )
339
+ function_component = FunctionGroupingComponent ( )
340
+ lineno_component = LineNumberGroupingComponent ( )
328
341
329
342
# The context line grouping information is the most reliable one.
330
343
# If we did not manage to find some information there, we want to
@@ -347,8 +360,8 @@ def frame_legacy(
347
360
if is_unhashable_function_legacy (func ):
348
361
function_component .update (
349
362
values = [
350
- BaseGroupingComponent (
351
- id = "salt" , values = ["<function>" ], hint = "normalized lambda function name"
363
+ SaltGroupingComponent (
364
+ values = ["<function>" ], hint = "normalized lambda function name"
352
365
)
353
366
]
354
367
)
@@ -380,8 +393,7 @@ def frame_legacy(
380
393
)
381
394
382
395
return {
383
- context ["variant" ]: BaseGroupingComponent (
384
- id = "frame" ,
396
+ context ["variant" ]: FrameGroupingComponent (
385
397
values = [
386
398
module_component ,
387
399
filename_component ,
@@ -461,8 +473,7 @@ def threads_legacy(
461
473
thread_count = len (interface .values )
462
474
if thread_count != 1 :
463
475
return {
464
- context ["variant" ]: BaseGroupingComponent (
465
- id = "threads" ,
476
+ context ["variant" ]: ThreadsGroupingComponent (
466
477
contributes = False ,
467
478
hint = "ignored because contains %d threads" % thread_count ,
468
479
)
@@ -471,14 +482,13 @@ def threads_legacy(
471
482
stacktrace = interface .values [0 ].get ("stacktrace" )
472
483
if not stacktrace :
473
484
return {
474
- context ["variant" ]: BaseGroupingComponent (
475
- id = "threads" , contributes = False , hint = "thread has no stacktrace"
485
+ context ["variant" ]: ThreadsGroupingComponent (
486
+ contributes = False , hint = "thread has no stacktrace"
476
487
)
477
488
}
478
489
479
490
return {
480
- context ["variant" ]: BaseGroupingComponent (
481
- id = "threads" ,
491
+ context ["variant" ]: ThreadsGroupingComponent (
482
492
values = [context .get_single_grouping_component (stacktrace , event = event , ** meta )],
483
493
)
484
494
}
0 commit comments