Skip to content

Commit 6e6cd39

Browse files
authored
ref(seer grouping): Add ability to ignore useless filenames (#85277)
A customer recently switched the build tool for their iOS app, and it changed their app's stacktraces such that new groups are now being created when ideally they wouldn't be. There were multiple differences in the stacktraces, not all easily mitigated, but one straightforward one was that some frames went from having no filename property to having a filename property of `<compiler-generated>`. To make it so that at least Seer will ignore this particular difference, this PR adds a list of filenames for us to ignore when constructing the stacktrace string we send it. We should also consider marking filename components with such filenames as non-contributing, but that will have to wait for a separate PR.
1 parent 6c5715a commit 6e6cd39

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/sentry/seer/similarity/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
"javascript;base64",
4444
]
4545

46+
IGNORED_FILENAMES = ["<compiler-generated>"]
47+
4648

4749
class ReferrerOptions(StrEnum):
4850
INGEST = "ingest"
@@ -239,6 +241,8 @@ def extract_filename(frame_dict: Mapping[str, Any]) -> str:
239241
Extract the filename from the frame dictionary. Fallback to module if filename is not present.
240242
"""
241243
filename = frame_dict["filename"]
244+
if filename in IGNORED_FILENAMES:
245+
filename = ""
242246
if filename == "" and frame_dict["module"] != "":
243247
filename = frame_dict["module"]
244248
return filename

tests/sentry/seer/similarity/test_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sentry.grouping.variants import CustomFingerprintVariant
99
from sentry.seer.similarity.utils import (
1010
BASE64_ENCODED_PREFIXES,
11+
IGNORED_FILENAMES,
1112
MAX_FRAME_COUNT,
1213
ReferrerOptions,
1314
_is_snipped_context_line,
@@ -811,6 +812,21 @@ def test_no_filename_or_module(self):
811812
== 'ZeroDivisionError: division by zero\n File "None", function divide_by_zero\n divide = 1/0'
812813
)
813814

815+
def test_ignores_meaningless_filenames(self):
816+
for ignored_filename in IGNORED_FILENAMES:
817+
exception = copy.deepcopy(self.BASE_APP_DATA)
818+
# delete module from the exception so we don't fall back to that
819+
del exception["app"]["component"]["values"][0]["values"][0]["values"][0]["values"][0]
820+
# replace filename with ignored value
821+
exception["app"]["component"]["values"][0]["values"][0]["values"][0]["values"][0][
822+
"values"
823+
][0] = ignored_filename
824+
stacktrace_string = get_stacktrace_string(exception)
825+
assert (
826+
stacktrace_string
827+
== 'ZeroDivisionError: division by zero\n File "None", function divide_by_zero\n divide = 1/0'
828+
)
829+
814830
@patch("sentry.seer.similarity.utils.metrics")
815831
def test_no_header_one_frame_no_filename(self, mock_metrics):
816832
exception = copy.deepcopy(self.MOBILE_THREAD_DATA)

0 commit comments

Comments
 (0)