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-7145] Remove support for profiling Ruby 2.2 #2592

Merged
merged 9 commits into from
Feb 1, 2023
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace :spec do
' spec/**/{auto_instrument,opentelemetry}_spec.rb'
t.rspec_opts = args.to_a.join(' ')
end
if RUBY_ENGINE == 'ruby' && OS.linux? && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
if RUBY_ENGINE == 'ruby' && OS.linux? && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0')
# "bundle exec rake compile" currently only works on MRI Ruby on Linux
Rake::Task[:main].enhance([:clean])
Rake::Task[:main].enhance([:compile])
Expand Down
1 change: 1 addition & 0 deletions ddtrace.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
]]
.select { |fn| File.file?(fn) } # We don't want directories, only files
.reject { |fn| fn.end_with?('.so', '.bundle') } # Exclude local profiler binary artifacts
.reject { |fn| fn.end_with?('skipped_reason.txt') } # Generated by profiler; should never be distributed

spec.executables = ['ddtracerb']
spec.require_paths = ['lib']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def self.unsupported_reason
on_macos? ||
on_unknown_os? ||
not_on_amd64_or_arm64? ||
on_ruby_2_1? ||
on_ruby_2_1_or_2_2? ||
ivoanjo marked this conversation as resolved.
Show resolved Hide resolved
expected_to_use_mjit_but_mjit_is_disabled? ||
libdatadog_not_available? ||
libdatadog_not_usable?
Expand Down Expand Up @@ -260,13 +260,13 @@ def self.pkg_config_missing?(command: $PKGCONFIG) # rubocop:disable Style/Global
architecture_not_supported unless RUBY_PLATFORM.start_with?('x86_64', 'aarch64', 'arm64')
end

private_class_method def self.on_ruby_2_1?
private_class_method def self.on_ruby_2_1_or_2_2?
ruby_version_not_supported = explain_issue(
'the profiler only supports Ruby 2.2 or newer.',
'the profiler only supports Ruby 2.3 or newer.',
suggested: UPGRADE_RUBY,
)

ruby_version_not_supported if RUBY_VERSION.start_with?('2.1.')
ruby_version_not_supported if RUBY_VERSION.start_with?('2.1.', '2.2.')
end

# On some Rubies, we require the mjit header to be present. If Ruby was installed without MJIT support, we also skip
Expand Down
3 changes: 1 addition & 2 deletions integration/apps/rack/spec/integration/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
it { is_expected.to be_a_kind_of(Net::HTTPOK) }
end

let(:expected_profiler_available) { RUBY_VERSION >= '2.2' }
let(:expected_profiler_available) { RUBY_VERSION >= '2.3' }

let(:expected_profiler_threads) do
# NOTE: Threads can't be named on Ruby 2.2
contain_exactly('Datadog::Profiling::Collectors::OldStack', 'Datadog::Profiling::Scheduler') unless RUBY_VERSION < '2.3'
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
it { is_expected.to be_a_kind_of(Net::HTTPOK) }
end

let(:expected_profiler_available) { RUBY_VERSION >= '2.2' }
let(:expected_profiler_available) { RUBY_VERSION >= '2.3' }

let(:expected_profiler_threads) do
# NOTE: Threads can't be named on Ruby 2.2
contain_exactly('Datadog::Profiling::Collectors::OldStack', 'Datadog::Profiling::Scheduler') unless RUBY_VERSION < '2.3'
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
it { is_expected.to be_a_kind_of(Net::HTTPOK) }
end

let(:expected_profiler_available) { RUBY_VERSION >= '2.2' }
let(:expected_profiler_available) { RUBY_VERSION >= '2.3' }

let(:expected_profiler_threads) do
# NOTE: Threads can't be named on Ruby 2.2
contain_exactly('Datadog::Profiling::Collectors::OldStack', 'Datadog::Profiling::Scheduler') unless RUBY_VERSION < '2.3'
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby

if local_gem_path = ENV['DD_DEMO_ENV_GEM_LOCAL_DDTRACE']
if RUBY_VERSION.start_with?('2.1.')
puts "\n== Skipping build of profiler native extension on Ruby 2.1 =="
if (RUBY_VERSION.start_with?('2.1.') || RUBY_VERSION.start_with?('2.2.'))
puts "\n== Skipping build of profiler native extension on Ruby 2.1/2.2 =="
else
puts "\n== Building profiler native extension =="
success =
Expand Down
12 changes: 9 additions & 3 deletions spec/datadog/profiling/native_extension_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
end

shared_examples 'supported ruby validation' do
context 'when not on Ruby 2.1' do
before { stub_const('RUBY_VERSION', '2.2.0') }
context 'when not on Ruby 2.1 or 2.2' do
before { stub_const('RUBY_VERSION', '2.3.0') }

shared_examples 'libdatadog available' do
context 'when libdatadog fails to activate' do
Expand Down Expand Up @@ -191,7 +191,13 @@
context 'when on Ruby 2.1' do
before { stub_const('RUBY_VERSION', '2.1.10') }

it { is_expected.to include 'profiler only supports Ruby 2.2 or newer' }
it { is_expected.to include 'profiler only supports Ruby 2.3 or newer' }
end

context 'when on Ruby 2.2' do
before { stub_const('RUBY_VERSION', '2.2.10') }

it { is_expected.to include 'profiler only supports Ruby 2.3 or newer' }
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/profiling/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def build_stack_sample(
def skip_if_profiling_not_supported(testcase)
testcase.skip('Profiling is not supported on JRuby') if PlatformHelpers.jruby?
testcase.skip('Profiling is not supported on TruffleRuby') if PlatformHelpers.truffleruby?
testcase.skip('Profiling is not supported on Ruby 2.1') if RUBY_VERSION.start_with?('2.1.')
testcase.skip('Profiling is not supported on Ruby 2.1/2.2') if RUBY_VERSION.start_with?('2.1.', '2.2.')

# Profiling is not officially supported on macOS due to missing libdatadog binaries,
# but it's still useful to allow it to be enabled for development.
Expand Down