-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
ref(derive_code_mappings): Process frames instead of file paths #85174
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
Conversation
For some languages (e.g. Java) we're going to process all frames, thus, we need to pass around more than the filenames.
@@ -48,20 +49,22 @@ class UnsupportedFrameFilename(Exception): | |||
|
|||
def derive_code_mappings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__(self, frame_file_path: str) -> None: | ||
def __init__(self, frame: Mapping[str, Any]) -> None: | ||
# XXX: In the next PR, we will use more than just the filename | ||
frame_file_path = frame["filename"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR for Java, we will use abs_path
and module
.
@@ -187,22 +190,24 @@ def list_file_matches(self, frame_filename: FrameFilename) -> list[dict[str, str | |||
) | |||
return file_matches | |||
|
|||
def _stacktrace_buckets(self, stacktraces: list[str]) -> dict[str, list[FrameFilename]]: | |||
def _stacktrace_buckets( | |||
self, frames: Sequence[Mapping[str, Any]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All along we had been passing the frames
but I mislabeled the variable.
@@ -11,3 +11,5 @@ | |||
] | |||
# These languages will run as dry-run mode by default | |||
DRY_RUN_PLATFORMS: list[str] = [] | |||
# Some languages will also process system frames | |||
PROCESS_ALL_FRAMES: list[str] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may one day do this for all platforms, however, for now, we will keep it to a short list.
if frame is None: | ||
continue | ||
if platform in PROCESS_ALL_FRAMES: | ||
frames_to_process.append(frame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the functional change to this function.
exceptions = get_path(data, "exception", "values", filter=True) | ||
if exceptions: | ||
return [e["stacktrace"] for e in exceptions if get_path(e, "stacktrace", "frames")] | ||
|
||
stacktrace = data.get("stacktrace") | ||
if stacktrace and stacktrace.get("frames"): | ||
logger.warning("Investigate if we use this code path in production.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason I believe we need this block is because of the way I wrote the tests. If this error doesn't happen in production I will remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally a preference thing, but I'd rather send an info event to Sentry here instead of a gcp log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelSun48 me as well! logger.warning()
captures a message in Sentry with a level of warning 👍🏻
@@ -47,14 +47,17 @@ def get(self, request: Request, organization: Organization) -> Response: | |||
:param string stacktraceFilename: | |||
:auth: required | |||
""" | |||
# XXX: Evaluate what else does the UI send us |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a task so I don't forget to check if "Set up code mappings" works for Java.
tests/sentry/issues/auto_source_code_config/test_code_mapping.py
Outdated
Show resolved
Hide resolved
def _stacktrace_with_frames(frames: list[dict[str, Any]]) -> Stacktrace: | ||
return {"stacktrace": {"frames": frames}} | ||
def _exception_with_stacktrace(frames: list[dict[str, Any]]) -> dict[str, Any]: | ||
return {"exception": {"values": [{"stacktrace": {"frames": frames}}]}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No functional changes in this test file besides data structure changes.
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #85174 +/- ##
===========================================
+ Coverage 46.25% 87.98% +41.73%
===========================================
Files 9614 9624 +10
Lines 542907 543473 +566
Branches 21042 21029 -13
===========================================
+ Hits 251112 478169 +227057
+ Misses 291489 65000 -226489
+ Partials 306 304 -2 |
def get_frames_to_process( | ||
data: NodeData | dict[str, Any], platform: str | None = None | ||
) -> list[dict[str, Any]]: | ||
"""It flattens all processableframes from the event's data.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""It flattens all processableframes from the event's data.""" | |
"""It flattens all processable frames from the event's data.""" |
exceptions = get_path(data, "exception", "values", filter=True) | ||
if exceptions: | ||
return [e["stacktrace"] for e in exceptions if get_path(e, "stacktrace", "frames")] | ||
|
||
stacktrace = data.get("stacktrace") | ||
if stacktrace and stacktrace.get("frames"): | ||
logger.warning("Investigate if we use this code path in production.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally a preference thing, but I'd rather send an info event to Sentry here instead of a gcp log.
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
For some languages (e.g. Java) we're going to process all frames, thus, we need to pass around more than the filenames.