Browse Source

Skip symbolicating internal Node frames (#49174)

Arpad Borsos 1 year ago
parent
commit
de5949a9a3

+ 10 - 7
src/sentry/lang/javascript/processing.py

@@ -141,15 +141,18 @@ def map_symbolicator_process_js_errors(errors):
     return mapped_errors
 
 
-def _handles_frame(frame):
+def _handles_frame(frame, data):
     if not frame:
         return False
 
-    # skip frames without an `abs_path`
-    if (abs_path := frame.get("abs_path")) is None:
+    # skip frames without an `abs_path` or line number
+    if not (abs_path := frame.get("abs_path")) or not frame.get("lineno"):
         return False
-    # skip "native" frames without a line
-    if abs_path in ("native", "[native code]") and frame.get("lineno", 0) == 0:
+    # skip "native" frames
+    if abs_path in ("native", "[native code]"):
+        return False
+    # skip builtin node modules
+    if data.get("platform") == "node" and not abs_path.startswith(("/", "app:", "webpack:")):
         return False
     return True
 
@@ -188,7 +191,7 @@ def process_js_stacktraces(symbolicator: Symbolicator, data: Any) -> Any:
             "frames": [
                 dict(frame)
                 for frame in sinfo.stacktrace.get("frames") or ()
-                if _handles_frame(frame)
+                if _handles_frame(frame, data)
             ],
         }
         for sinfo in stacktrace_infos
@@ -227,7 +230,7 @@ def process_js_stacktraces(symbolicator: Symbolicator, data: Any) -> Any:
         new_frames = []
         new_raw_frames = []
         for sinfo_frame in sinfo.stacktrace["frames"]:
-            if not _handles_frame(sinfo_frame):
+            if not _handles_frame(sinfo_frame, data):
                 new_raw_frames.append(sinfo_frame)
                 new_frames.append(sinfo_frame)
                 continue

+ 1 - 1
src/sentry/profiles/task.py

@@ -268,7 +268,7 @@ def _prepare_frames_from_profile(profile: Profile) -> Tuple[List[Any], List[Any]
         if "version" in profile:
             if profile["platform"] in JS_PLATFORMS:
                 for idx, f in enumerate(profile["profile"]["frames"]):
-                    if is_valid_javascript_frame(f):
+                    if is_valid_javascript_frame(f, profile):
                         frames_sent.add(idx)
 
                 frames = [profile["profile"]["frames"][idx] for idx in frames_sent]

+ 1 - 1
tests/sentry/profiles/test_task.py

@@ -413,7 +413,7 @@ class ProfilesProcessTaskTest(TestCase):
         frames_sent = [
             idx
             for idx, frame in enumerate(profile["profile"]["frames"])
-            if is_valid_javascript_frame(frame)
+            if is_valid_javascript_frame(frame, profile)
         ]
 
         _process_symbolicator_results_for_sample(profile, stacktraces, frames_sent)