Skip to content

Add Ruby 4.0#5084

Merged
lloeki merged 15 commits intomasterfrom
lloeki/add-ruby-4-0
Dec 1, 2025
Merged

Add Ruby 4.0#5084
lloeki merged 15 commits intomasterfrom
lloeki/add-ruby-4-0

Conversation

@lloeki
Copy link
Member

@lloeki lloeki commented Nov 24, 2025

What does this PR do?

Add Ruby 4.0 by moving from 3.5 (preview1) to 4.0 (preview2)

Motivation:

Ruby 3.5 isn't going to be a thing! Instead it's going to be 4.0.

Change log entry

None

Additional Notes:

How to test the change?

CI

@lloeki lloeki requested a review from a team as a code owner November 24, 2025 13:53
@lloeki lloeki marked this pull request as draft November 24, 2025 13:53
@pr-commenter
Copy link

pr-commenter bot commented Nov 24, 2025

Benchmarks

Benchmark execution time: 2025-12-01 16:01:27

Comparing candidate commit 0c2c259 in PR branch lloeki/add-ruby-4-0 with baseline commit c48f6ce in branch master.

Found 4 performance improvements and 0 performance regressions! Performance is the same for 40 metrics, 2 unstable metrics.

scenario:line instrumentation - targeted

  • 🟩 throughput [+11761.114op/s; +12380.431op/s] or [+8.216%; +8.649%]

scenario:line instrumentation - untargeted

  • 🟩 throughput [+5957.815op/s; +6112.144op/s] or [+11.189%; +11.479%]

scenario:method instrumentation

  • 🟩 throughput [+9706.769op/s; +10204.663op/s] or [+5.904%; +6.207%]

scenario:tracing - Propagation - Trace Context

  • 🟩 throughput [+3243.242op/s; +3347.286op/s] or [+9.567%; +9.874%]

@lloeki lloeki force-pushed the lloeki/add-ruby-4-0 branch from eacf8d5 to 18eace8 Compare November 24, 2025 14:59
@ivoanjo
Copy link
Member

ivoanjo commented Nov 24, 2025

Nice! I'm working on the profiling bits, feel free to throw in a disable for those and I'll take care to re-enable them once I have my fixes!

@lloeki lloeki force-pushed the lloeki/add-ruby-4-0 branch 3 times, most recently from a6c06b0 to e9c5e7c Compare November 24, 2025 16:16
@lloeki
Copy link
Member Author

lloeki commented Nov 24, 2025

Two fun ones yelling:

  2) Datadog::Core::Environment::Execution.development? when not in an RSpec test for Cucumber returns true
     Failure/Error: expect(err).to include('ACTUAL:true')

       expected "/Users/runner/hostedtoolcache/Ruby/4.0.0-preview2/arm64/lib/ruby/4.0.0+0/bundler/rubygems_integratio.../4.0.0-preview2/arm64/lib/ruby/4.0.0+0/rubygems.rb:233:in 'Gem.bin_path'\n\tfrom -:10:in '<main>'\n" to include "ACTUAL:true"
       Diff:
       @@ -1 +1,3 @@
       -ACTUAL:true
       +/Users/runner/hostedtoolcache/Ruby/4.0.0-preview2/arm64/lib/ruby/4.0.0+0/bundler/rubygems_integration.rb:236:in 'block in Gem.replace_bin_path': can't find executable cucumber for gem cucumber (Gem::Exception)
       +	from /Users/runner/hostedtoolcache/Ruby/4.0.0-preview2/arm64/lib/ruby/4.0.0+0/rubygems.rb:233:in 'Gem.bin_path'
       +	from -:10:in '<main>'
     # ./spec/datadog/core/environment/execution_spec.rb:196:in 'block (7 levels) in <top (required)>'
     # ./spec/datadog/core/environment/execution_spec.rb:186:in 'Dir.chdir'
     # ./spec/datadog/core/environment/execution_spec.rb:186:in 'block (6 levels) in <top (required)>'
     # ./spec/datadog/core/environment/execution_spec.rb:185:in 'block (5 levels) in <top (required)>'
     # ./spec/datadog/core/environment/execution_spec.rb:36:in 'block (4 levels) in <top (required)>'
     # ./spec/datadog/core/environment/execution_spec.rb:11:in 'block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:274:in 'block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:154:in 'block (2 levels) in <top (required)>'
     # ./spec/support/execute_in_fork.rb:32:in 'ForkableExample#run'
  3) Datadog::Core::Environment::Execution.development? when not in an RSpec test when in a Rails Spring process returns true
     Failure/Error: expect(err).to end_with('ACTUAL:true')
       expected "-:10: warning: already initialized constant ARGV\n/Users/runner/hostedtoolcache/Ruby/4.0.0-preview2/.../4.0.0-preview2/arm64/lib/ruby/4.0.0+0/rubygems.rb:233:in 'Gem.bin_path'\n\tfrom -:11:in '<main>'\n" to end with "ACTUAL:true"
     # ./spec/datadog/core/environment/execution_spec.rb:132:in 'block (5 levels) in <top (required)>'
     # ./spec/datadog/core/environment/execution_spec.rb:36:in 'block (4 levels) in <top (required)>'
     # ./spec/datadog/core/environment/execution_spec.rb:11:in 'block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:274:in 'block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:154:in 'block (2 levels) in <top (required)>'
     # ./spec/support/execute_in_fork.rb:32:in 'ForkableExample#run'

@lloeki lloeki marked this pull request as ready for review November 25, 2025 11:33
@lloeki lloeki marked this pull request as draft November 25, 2025 11:33
@ivoanjo
Copy link
Member

ivoanjo commented Nov 25, 2025

Update for profiling: Once these PRs are in

...the profiler should be green on Ruby 4. So skipping profiling specs probably won't be needed on this branch (just need to rebase once the above have landed)

ivoanjo added a commit that referenced this pull request Nov 25, 2025
**What does this PR do?**

This PR adds the `ruby-4.0.gemfile` file that's needed for running
`bundle install` on Ruby 4.0.0-preview2.

The contents of this file being added are copy/pasted from
`ruby-4.0.gemfile` with no changes.

I did not add or change anything on purpose: This is a very minimal
part of the Ruby 4 CI support being prepared in
#5084 but
unlocks local development with Ruby 4.0. I suggest we keep
adjustments/cleanups/etc for that later PR where we officially add Ruby
4.0 to our CI.

**Motivation:**

Without this file it's impossible to do local development on
Ruby 4.0.0-preview2.

It also came up in
<DataDog/datadog-ruby_core_source#19>:
we want to check if the profiler extension compiles on Ruby 4.0 and
we're not able without this file.

With this PR we can run `bundle install` and start running tests
and tackling what's missing.

**Additional Notes:**

N/A

**How to test the change?**

Validate that it's possible to run `bundle install` on Ruby 4.0.
@lloeki lloeki force-pushed the lloeki/add-ruby-4-0 branch 2 times, most recently from 90e4d06 to 093af67 Compare November 25, 2025 16:12
@lloeki
Copy link
Member Author

lloeki commented Nov 25, 2025

Rebased, but we still need a release for DataDog/datadog-ruby_core_source#18

Or we could hack something to temporarily point to git instead.

@ivoanjo
Copy link
Member

ivoanjo commented Nov 25, 2025

Or we could hack something to temporarily point to git instead.

I think it's fine to point to git specifically in the gemfile-4.0.rb? Possibly with a check that we're in a preview/head Ruby build (so it starts failing once we try to upgrade to 4.0.0 stable and we need to remove it)

@lloeki lloeki force-pushed the lloeki/add-ruby-4-0 branch from 8ea65c3 to b613d43 Compare November 25, 2025 16:43
@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Nov 25, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 50.00%
Total Coverage: 95.17% (+0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0c2c259 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@lloeki lloeki force-pushed the lloeki/add-ruby-4-0 branch 5 times, most recently from 3edbd9c to e29b181 Compare November 27, 2025 16:34
@lloeki lloeki marked this pull request as ready for review November 27, 2025 16:40
@lloeki lloeki force-pushed the lloeki/add-ruby-4-0 branch from e29b181 to 52b80ab Compare November 27, 2025 16:40
Copy link
Member

@Strech Strech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@lloeki lloeki force-pushed the lloeki/add-ruby-4-0 branch from d3cc2ad to 093fe5a Compare December 1, 2025 15:07
@lloeki lloeki merged commit d843f78 into master Dec 1, 2025
565 checks passed
@lloeki lloeki deleted the lloeki/add-ruby-4-0 branch December 1, 2025 16:30
@github-actions github-actions bot added this to the 2.23.0 milestone Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants