Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROF-11394] Graduate heap profiling from alpha to preview #4401

Merged
merged 1 commit into from
Feb 18, 2025
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
10 changes: 5 additions & 5 deletions lib/datadog/core/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def initialize(*_)

# Can be used to enable/disable the collection of heap profiles.
#
# This feature is alpha and disabled by default
# This feature is in preview and disabled by default. Requires Ruby 3.1+.
#
# @warn To enable heap profiling you are required to also enable allocation profiling.
#
Expand All @@ -326,12 +326,12 @@ def initialize(*_)

# Can be used to enable/disable the collection of heap size profiles.
#
# This feature is alpha and enabled by default when heap profiling is enabled.
# This feature is in preview and by default is enabled whenever heap profiling is enabled.
#
# @warn To enable heap size profiling you are required to also enable allocation and heap profiling.
# @warn Heap size profiling depends on allocation and heap profiling, so they must be enabled as well.
#
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED` environment variable as a boolean, otherwise
# whatever the value of DD_PROFILING_EXPERIMENTAL_HEAP_ENABLED is.
# @default `DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED` environment variable as a boolean, otherwise it
# follows the value of `experimental_heap_enabled`.
option :experimental_heap_size_enabled do |o|
o.type :bool
o.env 'DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED'
Expand Down
15 changes: 6 additions & 9 deletions lib/datadog/profiling/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,14 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:,
end

unless allocation_profiling_enabled
raise ArgumentError, "Heap profiling requires allocation profiling to be enabled"
logger.warn(
"Heap profiling was requested but allocation profiling is not enabled. " \
"Heap profiling has been disabled."
)
return false
end

logger.warn(
"Enabled experimental heap profiling: heap_sample_rate=#{heap_sample_rate}. This is experimental, not " \
"recommended, and will increase overhead!"
)
logger.debug("Enabled heap profiling: heap_sample_rate=#{heap_sample_rate}")

true
end
Expand All @@ -237,10 +238,6 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:,

return false unless heap_profiling_enabled && heap_size_profiling_enabled

logger.warn(
"Enabled experimental heap size profiling. This is experimental, not recommended, and will increase overhead!"
)

true
end

Expand Down
16 changes: 10 additions & 6 deletions spec/datadog/profiling/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,14 @@
settings.profiling.allocation_enabled = false
end

it "raises an ArgumentError during component initialization" do
expect { build_profiler_component }.to raise_error(ArgumentError, /requires allocation profiling/)
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(/allocation profiling is not enabled/)

build_profiler_component
end
end

Expand All @@ -350,8 +356,7 @@

expect(logger).to receive(:info).with(/Ractors.+stopping/)
expect(logger).to receive(:debug).with(/Enabled allocation profiling/)
expect(logger).to receive(:warn).with(/experimental heap profiling/)
expect(logger).to receive(:warn).with(/experimental heap size profiling/)
expect(logger).to receive(:debug).with(/Enabled heap profiling/)

build_profiler_component
end
Expand All @@ -368,8 +373,7 @@

expect(logger).to receive(:info).with(/Ractors.+stopping/)
expect(logger).to receive(:debug).with(/Enabled allocation profiling/)
expect(logger).to receive(:warn).with(/experimental heap profiling/)
expect(logger).not_to receive(:warn).with(/experimental heap size profiling/)
expect(logger).to receive(:debug).with(/Enabled heap profiling/)

build_profiler_component
end
Expand Down
Loading