Skip to content
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
6 changes: 6 additions & 0 deletions lib/datadog/profiling/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:,
"Please upgrade to Ruby >= 3.1 in order to use this feature. Heap profiling has been disabled."
)
return false
elsif RUBY_VERSION.start_with?("4.")
logger.warn(
"Heap profiling is not supported in current Ruby version (#{RUBY_VERSION}) due to https://bugs.ruby-lang.org/issues/21710. " \
"Heap profiling has been disabled."
)
return false
end

unless allocation_profiling_enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@

before do
skip "Heap profiling is only supported on Ruby >= 2.7" if RUBY_VERSION < "2.7"
skip "Heap profiling is disabled on Ruby 4 until https://bugs.ruby-lang.org/issues/21710 is fixed" if RUBY_VERSION.start_with?("4.")
allow(Datadog.logger).to receive(:warn)
expect(Datadog.logger).to receive(:warn).with(/dynamic sampling rate disabled/)
end
Expand Down
14 changes: 14 additions & 0 deletions spec/datadog/profiling/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,20 @@
end
end

context "on Ruby 4.0 or newer" do
let(:testing_version) { "4.0.0" }

it "initializes StackRecorder without heap sampling support and warns" do
expect(Datadog::Profiling::StackRecorder).to receive(:new)
.with(hash_including(heap_samples_enabled: false, heap_size_enabled: false))
.and_call_original

expect(logger).to receive(:warn).with(/Heap profiling is not supported.*21710/)

build_profiler_component
end
end

context "and allocation profiling disabled" do
before do
settings.profiling.allocation_enabled = false
Expand Down