Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(similarity): Add logging for over 30 system frames #81130

Merged
merged 8 commits into from
Nov 22, 2024

Conversation

jangjodi
Copy link
Contributor

Add logging for events with stacktraces with over 30 system-only frames

@jangjodi jangjodi requested a review from a team as a code owner November 21, 2024 16:53
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 21, 2024
Copy link
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we follow the pattern where we raise the exception we can catch and log then, so no need to pass anything extra into the function

@jangjodi
Copy link
Contributor Author

jangjodi commented Nov 21, 2024

if we follow the pattern where we raise the exception we can catch and log then, so no need to pass anything extra into the function

if we raise the exception, would we still be able to return the stacktrace string? I chose to do it this way so the grouping logic would not change yet.

also this is a temporary metric that we're gathering so we can look at some examples

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #81130      +/-   ##
==========================================
- Coverage   80.34%   80.30%   -0.04%     
==========================================
  Files        7225     7220       -5     
  Lines      320221   319346     -875     
  Branches    20781    20779       -2     
==========================================
- Hits       257268   256445     -823     
+ Misses      62559    62508      -51     
+ Partials      394      393       -1     

@jangjodi jangjodi requested a review from JoshFerge November 22, 2024 15:53
@@ -179,18 +179,22 @@ def get_stacktrace_string(data: dict[str, Any]) -> str:
html_frame_count = 0 # for a temporary metric
stacktrace_str = ""
found_non_snipped_context_line = False
is_frames_truncated = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
is_frames_truncated = False
are_frames_truncated = False

or

Suggested change
is_frames_truncated = False
were_frames_truncated = False

or

Suggested change
is_frames_truncated = False
is_truncated_stacktrace = False

etc.

Comment on lines +196 to +197
if len(contributing_frames) + frame_count > MAX_FRAME_COUNT:
is_frames_truncated = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might just be unclear variable naming (and not having read through the entire algorithm) which is getting me, but why are we adding contributing frames to all frames?

Also, nit:

Comparisons return a bool, so we can just use that directly.

Suggested change
if len(contributing_frames) + frame_count > MAX_FRAME_COUNT:
is_frames_truncated = True
is_frames_truncated = len(contributing_frames) + frame_count > MAX_FRAME_COUNT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're doing this to see if the length of all the contributing frames we've accumulated so far (either from this current exception or some previous ones) is greater than 30

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so basially contributing_frames is ones we've already counted and frame_count is ones we're about to add?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other way around, but yes that's the idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for the explanation!

Comment on lines +346 to +354
grouping_info = get_grouping_info_from_variants(variants)
mock_logger.info.assert_called_with(
"grouping.similarity.over_threshold_system_only_frames",
extra={
"project_id": "",
"event_id": "",
"hash": grouping_info["system"]["hash"],
},
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
grouping_info = get_grouping_info_from_variants(variants)
mock_logger.info.assert_called_with(
"grouping.similarity.over_threshold_system_only_frames",
extra={
"project_id": "",
"event_id": "",
"hash": grouping_info["system"]["hash"],
},
)
grouping_info = get_grouping_info_from_variants(variants)
grouping_info["event_id"] = 11212012123120120415201309082013
grouping_info["project_id"] = 12311121
mock_logger.info.assert_called_with(
"grouping.similarity.over_threshold_system_only_frames",
extra={
"project_id": 11212012123120120415201309082013,
"event_id": 12311121,
"hash": grouping_info["system"]["hash"],
},
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the case we're testing here is calling get_seer_similar_issues without modifying grouping_info first. so the case when this line is called.

this also doesn't work since grouping info is calculated in the function. we could mock it, but I think the other tests cover this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Okay, great. If we were doing this for real I might suggest moving adding the info into the grouping info helper itself (then you only have to do it in one place, I think?), but again, since this is temporary, I say 🚢 .

tests/sentry/seer/similarity/test_utils.py Show resolved Hide resolved
@jangjodi jangjodi merged commit a3dba87 into master Nov 22, 2024
50 checks passed
@jangjodi jangjodi deleted the jodi/similarity-system-frames-logging branch November 22, 2024 19:49
harshithadurai pushed a commit that referenced this pull request Nov 25, 2024
Add logging for events with stacktraces with over 30 system-only frames
evanh pushed a commit that referenced this pull request Nov 25, 2024
Add logging for events with stacktraces with over 30 system-only frames
@jangjodi jangjodi added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Nov 25, 2024
@getsentry-bot
Copy link
Contributor

PR reverted: 7b7e795

getsentry-bot added a commit that referenced this pull request Nov 25, 2024
andrewshie-sentry pushed a commit that referenced this pull request Dec 2, 2024
Add logging for events with stacktraces with over 30 system-only frames
andrewshie-sentry pushed a commit that referenced this pull request Dec 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components Trigger: Revert Add to a merged PR to revert it (skips CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants