8000 fix(sessions): Update session also for non sampled events and change … · tinylambda/sentry-python@4cce4b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cce4b5

Browse files
authored
fix(sessions): Update session also for non sampled events and change filter order (getsentry#1394)
We want to update the session for dropped events in case the event is dropped by sampling. Events dropped by other mechanisms should not update the session. See getsentry/develop#551
1 parent 1878f9b commit 4cce4b5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sentry_sdk/client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ def _should_capture(
260260
if ignored_by_config_option:
261261
return False
262262

263+
return True
264+
265+
def _should_sample_error(
266+
self,
267+
event, # type: Event
268+
):
269+
# type: (...) -> bool
263270
not_in_sample_rate = (
264271
self.options["sample_rate"] < 1.0
265272
and random.random() >= self.options["sample_rate"]
@@ -349,9 +356,13 @@ def capture_event(
349356
if session:
350357
self._update_session_from_event(session, event)
351358

352-
attachments = hint.get("attachments")
353359
is_transaction = event_opt.get("type") == "transaction"
354360

361+
if not is_transaction and not self._should_sample_error(event):
362+
return None
363+
364+
attachments = hint.get("attachments")
365+
355366
# this is outside of the `if` immediately below because even if we don't
356367
# use the value, we want to make sure we remove it before the event is
357368
# sent

0 commit comments

Comments
 (0)
0