Skip to content

Commit c823ca8

Browse files
authored
Merge pull request #5090 from DataDog/ivoanjo/prof-13115-disable-heap-profiling-ruby-4-preview
[PROF-13115] Disable heap profiling on Ruby 4 preview due to incompatibility
2 parents 7084871 + 662eed8 commit c823ca8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/datadog/profiling/component.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:,
220220
"Please upgrade to Ruby >= 3.1 in order to use this feature. Heap profiling has been disabled."
221221
)
222222
return false
223+
elsif RUBY_VERSION.start_with?("4.")
224+
logger.warn(
225+
"Heap profiling is not supported in current Ruby version (#{RUBY_VERSION}) due to https://bugs.ruby-lang.org/issues/21710. " \
226+
"Heap profiling has been disabled."
227+
)
228+
return false
223229
end
224230

225231
unless allocation_profiling_enabled

spec/datadog/profiling/collectors/cpu_and_wall_time_worker_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@
868868

869869
before do
870870
skip "Heap profiling is only supported on Ruby >= 2.7" if RUBY_VERSION < "2.7"
871+
skip "Heap profiling is disabled on Ruby 4 until https://bugs.ruby-lang.org/issues/21710 is fixed" if RUBY_VERSION.start_with?("4.")
871872
allow(Datadog.logger).to receive(:warn)
872873
expect(Datadog.logger).to receive(:warn).with(/dynamic sampling rate disabled/)
873874
end

spec/datadog/profiling/component_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,20 @@
334334
end
335335
end
336336

337+
context "on Ruby 4.0 or newer" do
338+
let(:testing_version) { "4.0.0" }
339+
340+
it "initializes StackRecorder without heap sampling support and warns" do
341+
expect(Datadog::Profiling::StackRecorder).to receive(:new)
342+
.with(hash_including(heap_samples_enabled: false, heap_size_enabled: false))
343+
.and_call_original
344+
345+
expect(logger).to receive(:warn).with(/Heap profiling is not supported.*21710/)
346+
347+
build_profiler_component
348+
end
349+
end
350+
337351
context "and allocation profiling disabled" do
338352
before do
339353
settings.profiling.allocation_enabled = false

0 commit comments

Comments
 (0)