Skip to content

Commit

Permalink
feat: Process scraping_attempts sent by Symbolicator (#57461)
Browse files Browse the repository at this point in the history
This appends the `scraping_attempts` sent by Symbolicator since
getsentry/symbolicator#1311 to an event's data.
  • Loading branch information
loewenheim authored Oct 4, 2023
1 parent a00454b commit 09d32c2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sentry/lang/javascript/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
30 changes: 30 additions & 0 deletions tests/relay_integration/lang/javascript/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 09d32c2

Please sign in to comment.