Browse Source

fix(similarity-embedding): Modify stacktrace string to match script (#65333)

Modify stacktrace string to match how the stracktrace string is
formatted in data-analysis script
Jodi Jang 1 year ago
parent
commit
fc788d09ab
1 changed files with 8 additions and 19 deletions
  1. 8 19
      src/sentry/api/endpoints/group_similar_issues_embeddings.py

+ 8 - 19
src/sentry/api/endpoints/group_similar_issues_embeddings.py

@@ -20,7 +20,6 @@ from sentry.seer.utils import (
     SimilarIssuesEmbeddingsRequest,
     get_similar_issues_embeddings,
 )
-from sentry.web.helpers import render_to_string
 
 logger = logging.getLogger(__name__)
 MAX_FRAME_COUNT = 50
@@ -32,7 +31,7 @@ def get_stacktrace_string(exception: Mapping[Any, Any], event: GroupEvent) -> st
         return ""
 
     frame_count = 0
-    output = []
+    output = ""
     for exc in exception["values"]:
         if not exc or not exc.get("stacktrace"):
             continue
@@ -49,27 +48,17 @@ def get_stacktrace_string(exception: Mapping[Any, Any], event: GroupEvent) -> st
             frame_count += num_frames
 
             if in_app_frames:
-                output.append(f'{exc["type"]}: {exc["value"]}')
+                output += exc.get("type") + ": " + exc.get("value") + "\n"
 
-            choices = [event.platform, "default"] if event.platform else ["default"]
-            templates = [f"sentry/partial/frames/{choice}.txt" for choice in choices]
             for frame in in_app_frames:
-                output.append(
-                    render_to_string(
-                        templates,
-                        {
-                            "abs_path": frame.get("abs_path"),
-                            "filename": frame.get("filename"),
-                            "function": frame.get("function"),
-                            "module": frame.get("module"),
-                            "lineno": frame.get("lineno"),
-                            "colno": frame.get("colno"),
-                            "context_line": frame.get("context_line"),
-                        },
-                    ).strip("\n")
+                output += '  File "{}", line {}, in {}\n    {}\n'.format(
+                    frame.get("filename", ""),
+                    frame.get("lineno", ""),
+                    frame.get("function", ""),
+                    frame.get("context_line", "").strip(),
                 )
 
-    return "\n".join(output)
+    return output.strip()
 
 
 class FormattedSimilarIssuesEmbeddingsData(TypedDict):