Skip to content

Commit bee83a5

Browse files
authored
ref(grouping): Simplify recursive frame handling (#97539)
In our grouping algorithm, we ignore recursion, that is to say, we count _n_ consecutive copies of a frame the same as if there were just 1 copy. Currently, in order to do this, we have the stacktrace strategy compare successive frames, and if recursion is detected, we add a flag to the grouping context so that all frames but the first in a recursion mark themselves as non-contributing. This works, but is more complicated than it needs to be. To simplify things, this PR lets the stacktrace component mark recursive frames non-contributing rather than having the frames do it themselves. This saves us from having to transmit that data through to the frame strategy, and therefore means we don't need to include the data in the grouping context.
1 parent f5010b5 commit bee83a5

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/sentry/grouping/strategies/configurations.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
],
2828
delegates=["frame:v1", "stacktrace:v1", "single-exception:v1"],
2929
initial_context={
30-
# This is a flag that can be used by any delegate to respond to
31-
# a detected recursion. This is currently used by the frame
32-
# strategy to disable itself. Recursion is detected by the outer
33-
# strategy.
34-
"is_recursion": False,
3530
# Perform automatic message trimming and parameter substitution in the message strategy.
3631
# (Should be kept on - only configurable so it can be turned off in tests.)
3732
"normalize_message": True,

src/sentry/grouping/strategies/newstyle.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@ def frame(
370370
):
371371
frame_component.update(contributes=False, hint="ignored low quality javascript frame")
372372

373-
if context["is_recursion"]:
374-
frame_component.update(contributes=False, hint="ignored due to recursion")
375-
376373
return {variant_name: frame_component}
377374

378375

@@ -437,9 +434,9 @@ def _single_stacktrace_variant(
437434
found_in_app_frame = False
438435

439436
for frame in frames:
440-
with context:
441-
context["is_recursion"] = _is_recursive_frame(frame, prev_frame)
442-
frame_component = context.get_single_grouping_component(frame, event=event, **kwargs)
437+
frame_component = context.get_single_grouping_component(frame, event=event, **kwargs)
438+
if _is_recursive_frame(frame, prev_frame):
439+
frame_component.update(contributes=False, hint="ignored due to recursion")
443440

444441
if variant_name == "app":
445442
if frame.in_app:

0 commit comments

Comments
 (0)