Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,19 @@ def _prepare_event(self, event, hint, scope):
return

if (
"exception" not in event
self.options["attach_stacktrace"]
and "exception" not in event
and "stacktrace" not in event
and self.options["attach_stacktrace"]
and "threads" not in event
):
with capture_internal_exceptions():
event["stacktrace"] = current_stacktrace()
event["threads"] = [
{
"stacktrace": current_stacktrace(),
"crashed": False,
"current": True,
}
]

for key in "release", "environment", "server_name", "dist":
if event.get(key) is None:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def bar():
foo()

event, = events
functions = [x["function"] for x in event["stacktrace"]["frames"]]
thread, = event["threads"]
functions = [x["function"] for x in thread["stacktrace"]["frames"]]
assert functions[-2:] == ["foo", "bar"]


Expand All @@ -115,7 +116,7 @@ def test_attach_stacktrace_disabled():
hub.capture_message("HI")

event, = events
assert "stacktrace" not in event
assert "threads" not in event


def test_capture_event_works():
Expand Down