From 40636ee078dd2db4c3cc870c42c46e39e05ea961 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Tue, 9 Oct 2018 09:55:43 +0200 Subject: [PATCH] fix: Don't use event.stacktrace --- sentry_sdk/client.py | 13 ++++++++++--- tests/test_client.py | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index acc4febeda..5f9a6ed502 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -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: diff --git a/tests/test_client.py b/tests/test_client.py index b29a9bf6e6..45950738c1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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"] @@ -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():