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-10015] Fix Phusion Passenger detection when not in Gemfile/gems.rb #3750

Merged
merged 1 commit into from
Jul 2, 2024
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: 5 additions & 1 deletion lib/datadog/profiling/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,12 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:)

# See https://github.com/datadog/dd-trace-rb/issues/2976 for details.
private_class_method def self.incompatible_passenger_version?
first_compatible_version = Gem::Version.new('6.0.19')

if Gem.loaded_specs['passenger']
Gem.loaded_specs['passenger'].version < Gem::Version.new('6.0.19')
Gem.loaded_specs['passenger'].version < first_compatible_version
elsif defined?(PhusionPassenger::VERSION_STRING)
Gem::Version.new(PhusionPassenger::VERSION_STRING) < first_compatible_version
else
true
end
Expand Down
23 changes: 23 additions & 0 deletions spec/datadog/profiling/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,29 @@
end
end

context 'when passenger gem is not available, but PhusionPassenger::VERSION_STRING is available' do
context 'on passenger >= 6.0.19' do
before { stub_const('PhusionPassenger::VERSION_STRING', '6.0.19') }

it { is_expected.to be false }
end

context 'on passenger < 6.0.19' do
before do
stub_const('PhusionPassenger::VERSION_STRING', '6.0.18')
allow(Datadog.logger).to receive(:warn)
end

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', passenger: nil, mysql2: nil, rugged: nil)

Expand Down
1 change: 1 addition & 0 deletions vendor/rbs/passenger/0/passenger.rbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module PhusionPassenger
VERSION_STRING: ::String
end
Loading