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
6 changes: 4 additions & 2 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ def _prepare_event(
if event.get("timestamp") is None:
event["timestamp"] = datetime.now(timezone.utc)

is_transaction = event.get("type") == "transaction"

if scope is not None:
is_transaction = event.get("type") == "transaction"
spans_before = len(cast(List[Dict[str, object]], event.get("spans", [])))
event_ = scope.apply_to_event(event, hint, self.options)

Expand Down Expand Up @@ -560,7 +561,8 @@ def _prepare_event(
)

if (
self.options["attach_stacktrace"]
not is_transaction
and self.options["attach_stacktrace"]
and "exception" not in event
and "stacktrace" not in event
and "threads" not in event
Expand Down
10 changes: 10 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
capture_exception,
capture_event,
set_tag,
start_transaction,
)
from sentry_sdk.spotlight import DEFAULT_SPOTLIGHT_URL
from sentry_sdk.utils import capture_internal_exception
Expand Down Expand Up @@ -562,6 +563,15 @@ def test_attach_stacktrace_disabled(sentry_init, capture_events):
assert "threads" not in event


def test_attach_stacktrace_transaction(sentry_init, capture_events):
sentry_init(traces_sample_rate=1.0, attach_stacktrace=True)
events = capture_events()
with start_transaction(name="transaction"):
pass
(event,) = events
assert "threads" not in event


def test_capture_event_works(sentry_init):
sentry_init(transport=_TestTransport())
pytest.raises(EnvelopeCapturedError, lambda: capture_event({}))
Expand Down