Skip to content

fix: Do not double sample transactions #732

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

Merged
merged 1 commit into from
Jun 23, 2020
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
4 changes: 4 additions & 0 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ def _should_capture(
scope=None, # type: Optional[Scope]
):
# type: (...) -> bool
if event.get("type") == "transaction":
# Transactions are sampled independent of error events.
return True

if scope is not None and not scope._should_capture:
return False

Expand Down
12 changes: 12 additions & 0 deletions tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,15 @@ def test_nested_span_sampling_override():
assert span.sampled is True
with Hub.current.start_span(transaction="inner", sampled=False) as span:
assert span.sampled is False


def test_no_double_sampling(sentry_init, capture_events):
# Transactions should not be subject to the global/error sample rate.
# Only the traces_sample_rate should apply.
sentry_init(traces_sample_rate=1.0, sample_rate=0.0)
events = capture_events()

with Hub.current.start_span(transaction="/"):
pass

assert len(events) == 1