Skip to content
Merged
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: 12 additions & 1 deletion sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ def _should_capture(
if ignored_by_config_option:
return False

return True

def _should_sample_error(
self,
event, # type: Event
):
# type: (...) -> bool
not_in_sample_rate = (
self.options["sample_rate"] < 1.0
and random.random() >= self.options["sample_rate"]
Expand Down Expand Up @@ -349,9 +356,13 @@ def capture_event(
if session:
self._update_session_from_event(session, event)

attachments = hint.get("attachments")
is_transaction = event_opt.get("type") == "transaction"

if not is_transaction and not self._should_sample_error(event):
return None

attachments = hint.get("attachments")

# this is outside of the `if` immediately below because even if we don't
# use the value, we want to make sure we remove it before the event is
# sent
Expand Down