diff --git a/sentry_sdk/integrations/opentelemetry/sampler.py b/sentry_sdk/integrations/opentelemetry/sampler.py index b5c500b3f3..e4c17a4aab 100644 --- a/sentry_sdk/integrations/opentelemetry/sampler.py +++ b/sentry_sdk/integrations/opentelemetry/sampler.py @@ -68,10 +68,11 @@ def dropped_result(parent_span_context, attributes, sample_rate=None): else: reason = "sample_rate" - client.transport.record_lost_event(reason, data_category="transaction") + if client.transport and has_tracing_enabled(client.options): + client.transport.record_lost_event(reason, data_category="transaction") - # Only one span (the transaction itself) is discarded, since we did not record any spans here. - client.transport.record_lost_event(reason, data_category="span") + # Only one span (the transaction itself) is discarded, since we did not record any spans here. + client.transport.record_lost_event(reason, data_category="span") return SamplingResult( Decision.DROP,