Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update session also for non sampled events and change filter order #1394

Merged
merged 6 commits into from Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion sentry_sdk/client.py
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