From 3388e494a4b6aa3e015fb342746ec7f290c09035 Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Fri, 26 Sep 2025 13:27:27 +0200 Subject: [PATCH] Don't send client reports for profiles if profiling is disabled --- CHANGELOG.md | 1 + sentry-ruby/lib/sentry/profiler.rb | 2 +- sentry-ruby/lib/sentry/vernier/profiler.rb | 2 +- sentry-ruby/spec/sentry_spec.rb | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09487ec3d..48ba0af30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ ### Internal - Archive [`sentry-raven`](https://github.com/getsentry/raven-ruby) ([#2708](https://github.com/getsentry/sentry-ruby/pull/2708)) +- Don't send `sample_rate` client reports for profiles if profiling is disabled ([#2728](https://github.com/getsentry/sentry-ruby/pull/2728)) ## 5.28.0 diff --git a/sentry-ruby/lib/sentry/profiler.rb b/sentry-ruby/lib/sentry/profiler.rb index 5d0b56639..5c5dd28a9 100644 --- a/sentry-ruby/lib/sentry/profiler.rb +++ b/sentry-ruby/lib/sentry/profiler.rb @@ -83,7 +83,7 @@ def set_initial_sample_decision(transaction_sampled) def to_h unless @sampled - record_lost_event(:sample_rate) + record_lost_event(:sample_rate) if @profiling_enabled return {} end diff --git a/sentry-ruby/lib/sentry/vernier/profiler.rb b/sentry-ruby/lib/sentry/vernier/profiler.rb index 3ec74942a..c3678eb70 100644 --- a/sentry-ruby/lib/sentry/vernier/profiler.rb +++ b/sentry-ruby/lib/sentry/vernier/profiler.rb @@ -92,7 +92,7 @@ def active_thread_id def to_h unless @sampled - record_lost_event(:sample_rate) + record_lost_event(:sample_rate) if @profiling_enabled return EMPTY_RESULT end diff --git a/sentry-ruby/spec/sentry_spec.rb b/sentry-ruby/spec/sentry_spec.rb index 8155c0514..18e9922b7 100644 --- a/sentry-ruby/spec/sentry_spec.rb +++ b/sentry-ruby/spec/sentry_spec.rb @@ -390,8 +390,8 @@ Sentry.get_current_client.flush - # 3 envelopes: log, transaction, and client_report about dropped profile - expect(sentry_envelopes.size).to be(3) + # 2 envelopes: log and transaction + expect(sentry_envelopes.size).to be(2) log_event = sentry_logs.first