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

Allow profiler to run without "no signals" workaround on passenger 6.0.19+ #3280

Merged
merged 1 commit into from
Nov 27, 2023
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
18 changes: 13 additions & 5 deletions lib/datadog/profiling/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,11 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:)
return true
end

if defined?(::PhusionPassenger)
if (defined?(::PhusionPassenger) || Gem.loaded_specs['passenger']) && incompatible_passenger_version?
Datadog.logger.warn(
'Enabling the profiling "no signals" workaround because the passenger web server is in use. ' \
'This is needed because passenger is currently incompatible with the normal working mode ' \
'of the profiler, as detailed in <https://github.com/DataDog/dd-trace-rb/issues/2976>. ' \
'Profiling data will have lower quality.'
'Enabling the profiling "no signals" workaround because an incompatible version of the passenger gem is ' \
'installed. Profiling data will have lower quality.' \
'To fix this, upgrade the passenger gem to version 6.0.19 or above.'
)
return true
end
Expand Down Expand Up @@ -237,6 +236,15 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:)
true
end
end

# See https://github.com/datadog/dd-trace-rb/issues/2976 for details.
private_class_method def self.incompatible_passenger_version?
if Gem.loaded_specs['passenger']
Gem.loaded_specs['passenger'].version < Gem::Version.new('6.0.19')
else
true
end
end
end
end
end
1 change: 1 addition & 0 deletions sig/datadog/profiling/component.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module Datadog
def self.no_signals_workaround_enabled?: (untyped settings) -> bool

def self.incompatible_libmysqlclient_version?: (untyped settings) -> bool
def self.incompatible_passenger_version?: () -> bool
end
end
end
28 changes: 26 additions & 2 deletions spec/datadog/profiling/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,9 @@
end
end

context 'when running inside the passenger web server' do
context 'when running inside the passenger web server, even when gem is not available' do
include_context('loaded gems', passenger: nil, rugged: nil, mysql2: nil)

before do
stub_const('::PhusionPassenger', Module.new)
allow(Datadog.logger).to receive(:warn)
Expand All @@ -495,8 +497,30 @@
end
end

context 'when passenger gem is available' do
context 'on passenger >= 6.0.19' do
include_context('loaded gems', passenger: Gem::Version.new('6.0.19'), rugged: nil, mysql2: nil)

it { is_expected.to be false }
end

context 'on passenger < 6.0.19' do
include_context('loaded gems', passenger: Gem::Version.new('6.0.18'), rugged: nil, mysql2: nil)

before { allow(Datadog.logger).to receive(:warn) }

it { is_expected.to be true }

it 'logs a warning message mentioning that the no signals workaround is going to be used' do
expect(Datadog.logger).to receive(:warn).with(/Enabling the profiling "no signals" workaround/)

no_signals_workaround_enabled?
end
end
end

context 'when mysql2 / rugged gems + passenger are not available' do
include_context('loaded gems', mysql2: nil, rugged: nil)
include_context('loaded gems', passenger: nil, mysql2: nil, rugged: nil)

it { is_expected.to be false }
end
Expand Down
Loading