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(
"Datadog Ruby heap profiler is currently incompatible with Ruby 4. " \
"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 @@ -865,7 +865,8 @@

before do
skip "Heap profiling is only supported on Ruby >= 2.7" if RUBY_VERSION < "2.7"
skip "Heap profiling is buggy on 4.0.0preview2 (https://bugs.ruby-lang.org/issues/21710) but fixed in master" if RUBY_DESCRIPTION.include?("4.0.0preview2")
skip "Datadog Heap profiling is incompatible with Ruby 4, see https://bugs.ruby-lang.org/issues/21710 for discussion" 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(/Datadog Ruby heap profiler is currently incompatible with Ruby 4/)

build_profiler_component
end
end

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