Skip to content

fix: Do not call before_send for transactions #731

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 25, 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
2 changes: 1 addition & 1 deletion sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _prepare_event(
event = serialize(event)

before_send = self.options["before_send"]
if before_send is not None:
if before_send is not None and event.get("type") != "transaction":
new_event = None
with capture_internal_exceptions():
new_event = before_send(event, hint or {})
Expand Down
13 changes: 13 additions & 0 deletions tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,16 @@ def test_no_double_sampling(sentry_init, capture_events):
pass

assert len(events) == 1


def test_transactions_do_not_go_through_before_send(sentry_init, capture_events):
def before_send(event, hint):
raise RuntimeError("should not be called")

sentry_init(traces_sample_rate=1.0, before_send=before_send)
events = capture_events()

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

assert len(events) == 1