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

Disable profiler on Ruby 3.3 due to incompatibility #3054

Merged
merged 5 commits into from
Aug 18, 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
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ 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.3.0')
if RUBY_ENGINE == 'ruby' && OS.linux? && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0') \
&& Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.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
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def self.unsupported_reason
on_unknown_os? ||
on_unsupported_cpu_arch? ||
on_unsupported_ruby_version? ||
on_ruby_3_3? ||
expected_to_use_mjit_but_mjit_is_disabled? ||
libdatadog_not_available? ||
libdatadog_not_usable?
Expand Down Expand Up @@ -269,6 +270,20 @@ def self.pkg_config_missing?(command: $PKGCONFIG) # rubocop:disable Style/Global
ruby_version_not_supported if RUBY_VERSION.start_with?('2.1.', '2.2.')
end

private_class_method def self.on_ruby_3_3?
incompatible_with_3_3 = explain_issue(
'the profiler in the current version of ddtrace does not yet support',
'Ruby version 3.3.',
'(See https://github.com/datadog/dd-trace-rb/issues/3053 for details).',
suggested: [
'Try upgrading to the latest ddtrace, as this issue may have been',
'fixed by now.',
] + CONTACT_SUPPORT,
)

incompatible_with_3_3 if RUBY_VERSION.start_with?('3.3.')
end

# On some Rubies, we require the mjit header to be present. If Ruby was installed without MJIT support, we also skip
# building the extension.
private_class_method def self.expected_to_use_mjit_but_mjit_is_disabled?
Expand Down
6 changes: 3 additions & 3 deletions integration/apps/rack/spec/integration/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
it { is_expected.to be_a_kind_of(Net::HTTPOK) }
end

let(:expected_profiler_available) { RUBY_VERSION >= '2.3' }
let(:expected_profiler_available) { RUBY_VERSION >= '2.3' && !RUBY_VERSION.start_with?('3.3.') }

let(:expected_profiler_threads) do
contain_exactly(
expected_profiler_available ? contain_exactly(
'Datadog::Profiling::Collectors::IdleSamplingHelper',
'Datadog::Profiling::Collectors::CpuAndWallTimeWorker',
'Datadog::Profiling::Scheduler',
) if RUBY_VERSION >= '2.3.'
) : eq(nil).or(eq([]))
end

context 'component checks' do
Expand Down
19 changes: 13 additions & 6 deletions integration/apps/rails-seven/spec/integration/basic_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'spec_helper'
require 'json'

RSpec.describe 'Basic scenarios' do
Expand All @@ -13,16 +14,22 @@

let(:json_result) { JSON.parse(subject.body, symbolize_names: true) }

let(:expected_profiler_available) { RUBY_VERSION >= '2.3' && !RUBY_VERSION.start_with?('3.3.') }

let(:expected_profiler_threads) do
expected_profiler_available ? contain_exactly(
'Datadog::Profiling::Collectors::IdleSamplingHelper',
'Datadog::Profiling::Collectors::CpuAndWallTimeWorker',
'Datadog::Profiling::Scheduler',
) : eq(nil).or(eq([]))
end

it { is_expected.to be_a_kind_of(Net::HTTPOK) }

it 'should be profiling' do
expect(json_result).to include(
profiler_available: true,
profiler_threads: contain_exactly(
'Datadog::Profiling::Collectors::IdleSamplingHelper',
'Datadog::Profiling::Collectors::CpuAndWallTimeWorker',
'Datadog::Profiling::Scheduler',
),
profiler_available: expected_profiler_available,
profiler_threads: expected_profiler_threads,
)
end

Expand Down
8 changes: 5 additions & 3 deletions integration/apps/rails-six/spec/integration/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@

let(:json_result) { JSON.parse(subject.body, symbolize_names: true) }

let(:expected_profiler_available) { RUBY_VERSION >= '2.3' && !RUBY_VERSION.start_with?('3.3.') }

let(:expected_profiler_threads) do
contain_exactly(
expected_profiler_available ? contain_exactly(
'Datadog::Profiling::Collectors::IdleSamplingHelper',
'Datadog::Profiling::Collectors::CpuAndWallTimeWorker',
'Datadog::Profiling::Scheduler',
)
) : eq(nil).or(eq([]))
end

it { is_expected.to be_a_kind_of(Net::HTTPOK) }

it 'should be profiling' do
expect(json_result).to include(
profiler_available: true,
profiler_available: expected_profiler_available,
profiler_threads: expected_profiler_threads,
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
it { is_expected.to be_a_kind_of(Net::HTTPOK) }
end

let(:expected_profiler_available) { RUBY_VERSION >= '2.3' }
let(:expected_profiler_available) { RUBY_VERSION >= '2.3' && !RUBY_VERSION.start_with?('3.3.') }

let(:expected_profiler_threads) do
contain_exactly(
expected_profiler_available ? contain_exactly(
'Datadog::Profiling::Collectors::IdleSamplingHelper',
'Datadog::Profiling::Collectors::CpuAndWallTimeWorker',
'Datadog::Profiling::Scheduler',
)
) : eq(nil).or(eq([]))
end

context 'component checks' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
it { is_expected.to be_a_kind_of(Net::HTTPOK) }
end

let(:expected_profiler_available) { RUBY_VERSION >= '2.3' }
let(:expected_profiler_available) { RUBY_VERSION >= '2.3' && !RUBY_VERSION.start_with?('3.3.') }

let(:expected_profiler_threads) do
contain_exactly(
expected_profiler_available ? contain_exactly(
'Datadog::Profiling::Collectors::IdleSamplingHelper',
'Datadog::Profiling::Collectors::CpuAndWallTimeWorker',
'Datadog::Profiling::Scheduler',
)
) : eq(nil).or(eq([]))
end

context 'component checks' do
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.', '2.2.')
puts "\n== Skipping build of profiler native extension on Ruby 2.1/2.2 =="
if RUBY_VERSION.start_with?('2.1.', '2.2.', '3.3.')
puts "\n== Skipping build of profiler native extension on Ruby 2.1/2.2 + 3.3 =="
else
puts "\n== Building profiler native extension =="
success =
Expand Down
6 changes: 6 additions & 0 deletions spec/datadog/profiling/native_extension_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@

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

context 'when on Ruby 3.3' do
before { stub_const('RUBY_VERSION', '3.3.0') }

it { is_expected.to include "does not yet support\nRuby version 3.3." }
end
end

context 'when on amd64 (x86-64) linux' do
Expand Down
3 changes: 3 additions & 0 deletions spec/datadog/profiling/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ 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/2.2') if RUBY_VERSION.start_with?('2.1.', '2.2.')
if RUBY_VERSION.start_with?('3.3.')
testcase.skip('Profiling is currently not supported on Ruby 3.3 (https://github.com/DataDog/dd-trace-rb/issues/3053)')
end

# 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