Skip to content

Commit 7b7e795

Browse files
Revert "chore(similarity): Add logging for over 30 system frames (#81130)"
This reverts commit a3dba87. Co-authored-by: jangjodi <[email protected]>
1 parent a071e2a commit 7b7e795

File tree

6 files changed

+2
-181
lines changed

6 files changed

+2
-181
lines changed

src/sentry/grouping/ingest/seer.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,7 @@ def _circuit_breaker_broken(event: Event, project: Project) -> bool:
182182

183183

184184
def _has_empty_stacktrace_string(event: Event, variants: Mapping[str, BaseVariant]) -> bool:
185-
# Temporarily add project and event id to this for logging purposes
186-
# TODO: Remove when grouping.similarity.over_threshold_system_only_frames is removed
187-
grouping_info = get_grouping_info_from_variants(variants)
188-
grouping_info["project_id"] = event.project.id # type: ignore[assignment]
189-
grouping_info["event_id"] = event.event_id # type: ignore[assignment]
190-
stacktrace_string = get_stacktrace_string(grouping_info)
185+
stacktrace_string = get_stacktrace_string(get_grouping_info_from_variants(variants))
191186
if stacktrace_string == "":
192187
metrics.incr(
193188
"grouping.similarity.did_call_seer",

src/sentry/seer/similarity/utils.py

-12
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,18 @@ def get_stacktrace_string(data: dict[str, Any]) -> str:
179179
html_frame_count = 0 # for a temporary metric
180180
stacktrace_str = ""
181181
found_non_snipped_context_line = False
182-
is_frames_truncated = False
183182

184183
metrics.distribution("seer.grouping.exceptions.length", len(exceptions))
185184

186185
def _process_frames(frames: list[dict[str, Any]]) -> list[str]:
187186
nonlocal frame_count
188187
nonlocal html_frame_count
189188
nonlocal found_non_snipped_context_line
190-
nonlocal is_frames_truncated
191189
frame_strings = []
192190

193191
contributing_frames = [
194192
frame for frame in frames if frame.get("id") == "frame" and frame.get("contributes")
195193
]
196-
if len(contributing_frames) + frame_count > MAX_FRAME_COUNT:
197-
is_frames_truncated = True
198194
contributing_frames = _discard_excess_frames(
199195
contributing_frames, MAX_FRAME_COUNT, frame_count
200196
)
@@ -291,14 +287,6 @@ def _process_frames(frames: list[dict[str, Any]]) -> list[str]:
291287
},
292288
)
293289

294-
if is_frames_truncated and not app_hash:
295-
logger_extra = {
296-
"project_id": data.get("project_id", ""),
297-
"event_id": data.get("event_id", ""),
298-
"hash": system_hash,
299-
}
300-
logger.info("grouping.similarity.over_threshold_system_only_frames", extra=logger_extra)
301-
302290
return stacktrace_str.strip()
303291

304292

src/sentry/tasks/embeddings_grouping/utils.py

-4
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,6 @@ def get_events_from_nodestore(
355355
event._project_cache = project
356356
if event and event.data and event_content_has_stacktrace(event):
357357
grouping_info = get_grouping_info(None, project=project, event=event)
358-
# Temporarily add project and event id to this for logging purposes
359-
# TODO: Remove when grouping.similarity.over_threshold_system_only_frames is removed
360-
grouping_info["project_id"] = project.id
361-
grouping_info["event_id"] = event.event_id # type: ignore[assignment]
362358
stacktrace_string = get_stacktrace_string(grouping_info)
363359
if stacktrace_string == "":
364360
invalid_event_group_ids.append(group_id)

tests/sentry/grouping/ingest/test_seer.py

-46
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
from sentry import options
66
from sentry.conf.server import SEER_SIMILARITY_MODEL_VERSION
77
from sentry.eventstore.models import Event
8-
from sentry.grouping.grouping_info import get_grouping_info_from_variants
98
from sentry.grouping.ingest.seer import get_seer_similar_issues, should_call_seer_for_grouping
109
from sentry.models.grouphash import GroupHash
1110
from sentry.seer.similarity.types import SeerSimilarIssueData
12-
from sentry.seer.similarity.utils import MAX_FRAME_COUNT
1311
from sentry.testutils.cases import TestCase
1412
from sentry.testutils.helpers.eventprocessing import save_new_event
1513
from sentry.testutils.helpers.options import override_options
@@ -308,47 +306,3 @@ def test_returns_no_grouphash_and_empty_metadata_if_no_similar_group_found(self)
308306
expected_metadata,
309307
None,
310308
)
311-
312-
@patch("sentry.seer.similarity.utils.logger")
313-
def test_too_many_only_system_frames(self, mock_logger: Mock) -> None:
314-
type = "FailedToFetchError"
315-
value = "Charlie didn't bring the ball back"
316-
context_line = f"raise {type}('{value}')"
317-
new_event = Event(
318-
project_id=self.project.id,
319-
event_id="22312012112120120908201304152013",
320-
data={
321-
"title": f"{type}('{value}')",
322-
"exception": {
323-
"values": [
324-
{
325-
"type": type,
326-
"value": value,
327-
"stacktrace": {
328-
"frames": [
329-
{
330-
"function": f"play_fetch_{i}",
331-
"filename": f"dogpark{i}.py",
332-
"context_line": context_line,
333-
}
334-
for i in range(MAX_FRAME_COUNT + 1)
335-
]
336-
},
337-
}
338-
]
339-
},
340-
"platform": "python",
341-
},
342-
)
343-
variants = new_event.get_grouping_variants()
344-
get_seer_similar_issues(new_event, variants)
345-
346-
grouping_info = get_grouping_info_from_variants(variants)
347-
mock_logger.info.assert_called_with(
348-
"grouping.similarity.over_threshold_system_only_frames",
349-
extra={
350-
"project_id": "",
351-
"event_id": "",
352-
"hash": grouping_info["system"]["hash"],
353-
},
354-
)

tests/sentry/seer/similarity/test_utils.py

+1-49
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import copy
22
from collections.abc import Callable
33
from typing import Any, Literal, cast
4-
from unittest.mock import patch
54
from uuid import uuid1
65

76
from sentry.eventstore.models import Event
87
from sentry.seer.similarity.utils import (
98
BASE64_ENCODED_PREFIXES,
10-
MAX_FRAME_COUNT,
119
SEER_ELIGIBLE_PLATFORMS,
1210
_is_snipped_context_line,
1311
event_content_is_seer_eligible,
@@ -712,53 +710,7 @@ def test_no_app_no_system(self):
712710
stacktrace_str = get_stacktrace_string(data)
713711
assert stacktrace_str == ""
714712

715-
@patch("sentry.seer.similarity.utils.logger")
716-
def test_too_many_system_frames_single_exception(self, mock_logger):
717-
data_system = copy.deepcopy(self.BASE_APP_DATA)
718-
data_system["system"] = data_system.pop("app")
719-
data_system["system"]["component"]["values"][0]["values"][0][
720-
"values"
721-
] += self.create_frames(MAX_FRAME_COUNT + 1, True)
722-
data_system["project_id"] = self.project.id
723-
data_system["event_id"] = "39485673049520"
724-
725-
get_stacktrace_string(data_system)
726-
727-
mock_logger.info.assert_called_with(
728-
"grouping.similarity.over_threshold_system_only_frames",
729-
extra={
730-
"project_id": self.project.id,
731-
"event_id": data_system["event_id"],
732-
"hash": data_system["system"]["hash"],
733-
},
734-
)
735-
736-
@patch("sentry.seer.similarity.utils.logger")
737-
def test_too_many_system_frames_chained_exception(self, mock_logger):
738-
data_system = copy.deepcopy(self.CHAINED_APP_DATA)
739-
data_system["system"] = data_system.pop("app")
740-
data_system["project_id"] = self.project.id
741-
data_system["event_id"] = "39485673049520"
742-
# Split MAX_FRAME_COUNT across the two exceptions
743-
data_system["system"]["component"]["values"][0]["values"][0]["values"][0][
744-
"values"
745-
] += self.create_frames(MAX_FRAME_COUNT // 2, True)
746-
data_system["system"]["component"]["values"][0]["values"][1]["values"][0][
747-
"values"
748-
] += self.create_frames(MAX_FRAME_COUNT // 2, True)
749-
750-
get_stacktrace_string(data_system)
751-
752-
mock_logger.info.assert_called_with(
753-
"grouping.similarity.over_threshold_system_only_frames",
754-
extra={
755-
"project_id": self.project.id,
756-
"event_id": data_system["event_id"],
757-
"hash": data_system["system"]["hash"],
758-
},
759-
)
760-
761-
def test_too_many_in_app_contributing_frames(self):
713+
def test_over_30_contributing_frames(self):
762714
"""Check that when there are over 30 contributing frames, the last 30 are included."""
763715

764716
data_frames = copy.deepcopy(self.BASE_APP_DATA)

tests/sentry/tasks/test_backfill_seer_grouping_records.py

-64
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from sentry.models.grouphash import GroupHash
2626
from sentry.seer.similarity.grouping_records import CreateGroupingRecordData
2727
from sentry.seer.similarity.types import RawSeerSimilarIssueData
28-
from sentry.seer.similarity.utils import MAX_FRAME_COUNT
2928
from sentry.snuba.dataset import Dataset
3029
from sentry.snuba.referrer import Referrer
3130
from sentry.tasks.embeddings_grouping.backfill_seer_grouping_records_for_project import (
@@ -366,69 +365,6 @@ def test_lookup_group_data_stacktrace_bulk_no_stacktrace_exception(self):
366365
assert bulk_group_data_stacktraces["data"] == expected_group_data
367366
assert bulk_group_data_stacktraces["stacktrace_list"] == expected_stacktraces
368367

369-
@patch("sentry.seer.similarity.utils.logger")
370-
def test_lookup_group_data_stacktrace_bulk_too_many_system_frames(self, mock_logger):
371-
"""
372-
Test that if a group has over MAX_FRAME_COUNT only system frames, it is logged
373-
and included in results
374-
"""
375-
# Use 2 events
376-
rows, events, hashes = self.bulk_rows[:2], self.bulk_events[:2], {}
377-
group_ids = [row["group_id"] for row in rows]
378-
for group_id in group_ids:
379-
hashes.update({group_id: self.group_hashes[group_id]})
380-
# Create one event where the stacktrace has over MAX_FRAME_COUNT system only frames
381-
exception: Any = copy.deepcopy(EXCEPTION)
382-
exception["values"][0]["stacktrace"]["frames"] += [
383-
{
384-
"function": f"divide_by_zero_{i}",
385-
"module": "__main__",
386-
"filename": "python_onboarding_{i}.py",
387-
"abs_path": "/Users/user/python_onboarding/python_onboarding_{i}.py",
388-
"lineno": i,
389-
"in_app": True,
390-
}
391-
for i in range(MAX_FRAME_COUNT + 1)
392-
]
393-
event = self.store_event(
394-
data={
395-
"platform": "python",
396-
"exception": exception,
397-
"title": "title",
398-
"timestamp": before_now(seconds=10).isoformat(),
399-
},
400-
project_id=self.project.id,
401-
assert_no_errors=False,
402-
)
403-
rows.append({"event_id": event.event_id, "group_id": event.group_id})
404-
group_hash = GroupHash.objects.filter(group_id=event.group.id).first()
405-
assert group_hash
406-
hashes.update({event.group_id: group_hash.hash})
407-
events.append(event)
408-
409-
bulk_group_data_stacktraces, _ = get_events_from_nodestore(self.project, rows, group_ids)
410-
expected_group_data = [
411-
CreateGroupingRecordData(
412-
group_id=event.group.id,
413-
hash=hashes[event.group.id],
414-
project_id=self.project.id,
415-
exception_type=get_path(event.data, "exception", "values", -1, "type"),
416-
)
417-
for event in events
418-
]
419-
420-
assert bulk_group_data_stacktraces["data"] == expected_group_data
421-
assert len(bulk_group_data_stacktraces["stacktrace_list"]) == len(events)
422-
423-
mock_logger.info.assert_called_with(
424-
"grouping.similarity.over_threshold_system_only_frames",
425-
extra={
426-
"project_id": self.project.id,
427-
"event_id": event.event_id,
428-
"hash": group_hash.hash,
429-
},
430-
)
431-
432368
def test_lookup_group_data_stacktrace_bulk_with_fallback_success(self):
433369
"""Test successful bulk lookup with fallback, where the fallback isn't used"""
434370
rows, events, hashes = (

0 commit comments

Comments
 (0)