From 09d32c20b54ae74564a841980829930afcd5fde7 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Wed, 4 Oct 2023 14:40:24 +0200 Subject: [PATCH] feat: Process scraping_attempts sent by Symbolicator (#57461) This appends the `scraping_attempts` sent by Symbolicator since https://github.com/getsentry/symbolicator/pull/1311 to an event's data. --- src/sentry/lang/javascript/processing.py | 3 ++ .../lang/javascript/test_plugin.py | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/sentry/lang/javascript/processing.py b/src/sentry/lang/javascript/processing.py index 131a546fbc013e..84b5ae825427b5 100644 --- a/src/sentry/lang/javascript/processing.py +++ b/src/sentry/lang/javascript/processing.py @@ -248,6 +248,9 @@ def process_js_stacktraces(symbolicator: Symbolicator, data: Any) -> Any: processing_errors = response.get("errors", []) if len(processing_errors) > 0: data.setdefault("errors", []).extend(map_symbolicator_process_js_errors(processing_errors)) + scraping_attempts = response.get("scraping_attempts", []) + if len(scraping_attempts) > 0: + data["scraping_attempts"] = scraping_attempts assert len(stacktraces) == len(response["stacktraces"]), (stacktraces, response) diff --git a/tests/relay_integration/lang/javascript/test_plugin.py b/tests/relay_integration/lang/javascript/test_plugin.py index 7cd6f9c7f9a5a8..83302b45b5ccaa 100644 --- a/tests/relay_integration/lang/javascript/test_plugin.py +++ b/tests/relay_integration/lang/javascript/test_plugin.py @@ -373,6 +373,12 @@ def test_sourcemap_source_expansion(self): } ] + assert event.data["scraping_attempts"] == [ + {"status": "not_attempted", "url": "http://example.com/file.min.js"}, + {"status": "not_attempted", "url": "http://example.com/file.sourcemap.js"}, + {"status": "not_attempted", "url": "http://example.com/file1.js"}, + ] + exception = event.interfaces["exception"] frame_list = exception.values[0].stacktrace.frames @@ -468,6 +474,13 @@ def test_sourcemap_webpack(self): exception = event.interfaces["exception"] frame_list = exception.values[0].stacktrace.frames + assert event.data["scraping_attempts"] == [ + {"url": "http://example.com/webpack1.min.js", "status": "not_attempted"}, + {"url": "http://example.com/webpack1.min.js.map", "status": "not_attempted"}, + {"url": "http://example.com/webpack2.min.js", "status": "not_attempted"}, + {"url": "http://example.com/webpack2.min.js.map", "status": "not_attempted"}, + ] + # The first frame should be in_app. first_frame = frame_list[0] assert first_frame.in_app @@ -563,6 +576,11 @@ def test_sourcemap_embedded_source_expansion(self): } ] + assert event.data["scraping_attempts"] == [ + {"status": "not_attempted", "url": "http://example.com/embedded.js"}, + {"status": "not_attempted", "url": "http://example.com/embedded.js.map"}, + ] + exception = event.interfaces["exception"] frame_list = exception.values[0].stacktrace.frames @@ -628,6 +646,11 @@ def test_sourcemap_nofiles_source_expansion(self): assert "errors" not in event.data + assert event.data["scraping_attempts"] == [ + {"url": "app:///nofiles.js", "status": "not_attempted"}, + {"url": "app:///nofiles.js.map", "status": "not_attempted"}, + ] + exception = event.interfaces["exception"] frame_list = exception.values[0].stacktrace.frames @@ -699,6 +722,13 @@ def test_indexed_sourcemap_source_expansion(self): assert "errors" not in event.data + assert event.data["scraping_attempts"] == [ + {"status": "not_attempted", "url": "http://example.com/indexed.min.js"}, + {"status": "not_attempted", "url": "http://example.com/indexed.sourcemap.js"}, + {"status": "not_attempted", "url": "http://example.com/file1.js"}, + {"status": "not_attempted", "url": "http://example.com/file2.js"}, + ] + exception = event.interfaces["exception"] frame_list = exception.values[0].stacktrace.frames