Skip to content

Commit 8b875c1

Browse files
authored
Fix broken sampler after backpressure change (#3702)
1 parent 43ca6f3 commit 8b875c1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sentry_sdk/integrations/opentelemetry/sampler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ def dropped_result(parent_span_context, attributes, sample_rate=None):
6868
else:
6969
reason = "sample_rate"
7070

71-
client.transport.record_lost_event(reason, data_category="transaction")
71+
if client.transport and has_tracing_enabled(client.options):
72+
client.transport.record_lost_event(reason, data_category="transaction")
7273

73-
# Only one span (the transaction itself) is discarded, since we did not record any spans here.
74-
client.transport.record_lost_event(reason, data_category="span")
74+
# Only one span (the transaction itself) is discarded, since we did not record any spans here.
75+
client.transport.record_lost_event(reason, data_category="span")
7576

7677
return SamplingResult(
7778
Decision.DROP,

0 commit comments

Comments
 (0)