From 8f46d9a1caf2e61c10eefe293a165e8dae423db2 Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Mon, 8 Dec 2025 10:22:15 -0500 Subject: [PATCH 1/8] Including ruby engine in metadata in logs --- lib/mongo/server/app_metadata/platform.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/mongo/server/app_metadata/platform.rb b/lib/mongo/server/app_metadata/platform.rb index 0df1b85459..d8f502415c 100644 --- a/lib/mongo/server/app_metadata/platform.rb +++ b/lib/mongo/server/app_metadata/platform.rb @@ -34,21 +34,21 @@ def initialize(metadata) @metadata = metadata end - # Queries whether the current runtime is JRuby or not. + # Queries whether the current runtime is Ruby or not. # - # @return [ true | false ] whether the runtime is JRuby or not. - def jruby? - BSON::Environment.jruby? + # @return [ Boolean ] whether the current runtime is Ruby + def ruby? + RUBY_ENGINE == 'ruby' end # Returns the list of Ruby versions that identify this runtime. # # @return [ Array ] the list of ruby versions def ruby_versions - if jruby? - [ "JRuby #{JRUBY_VERSION}", "like Ruby #{RUBY_VERSION}" ] - else + if ruby? [ "Ruby #{RUBY_VERSION}" ] + else + [ "#{RUBY_ENGINE} #{RUBY_ENGINE_VERSION}", "like Ruby #{RUBY_VERSION}" ] end end From a1b6fe06811d317bc4d01fd95d656ac400afea5f Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Mon, 8 Dec 2025 10:31:04 -0500 Subject: [PATCH 2/8] updating comment --- lib/mongo/server/app_metadata/platform.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mongo/server/app_metadata/platform.rb b/lib/mongo/server/app_metadata/platform.rb index d8f502415c..42279efcde 100644 --- a/lib/mongo/server/app_metadata/platform.rb +++ b/lib/mongo/server/app_metadata/platform.rb @@ -34,9 +34,9 @@ def initialize(metadata) @metadata = metadata end - # Queries whether the current runtime is Ruby or not. + # Queries whether the current runtime is standard Ruby or not. # - # @return [ Boolean ] whether the current runtime is Ruby + # @return [ Boolean ] whether the current runtime is standard Ruby def ruby? RUBY_ENGINE == 'ruby' end From 99bca3529f7e7c162931fc9483f9bb5755e7c363 Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Mon, 8 Dec 2025 10:35:02 -0500 Subject: [PATCH 3/8] changing capitalization of tests to work with new changes --- spec/support/shared/app_metadata.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/support/shared/app_metadata.rb b/spec/support/shared/app_metadata.rb index 8f44ac78c7..d85cd78ba7 100644 --- a/spec/support/shared/app_metadata.rb +++ b/spec/support/shared/app_metadata.rb @@ -83,7 +83,7 @@ def target_arch require_jruby it 'includes JRuby and Ruby compatibility versions' do - document[:client][:platform].should start_with("JRuby #{JRUBY_VERSION}, like Ruby #{RUBY_VERSION}") + document[:client][:platform].should start_with("jruby #{JRUBY_VERSION}, like Ruby #{RUBY_VERSION}") end context 'when custom platform is specified' do @@ -92,7 +92,7 @@ def target_arch end it 'starts with custom platform' do - document[:client][:platform].should start_with("foowidgets, JRuby #{JRUBY_VERSION}") + document[:client][:platform].should start_with("foowidgets, jruby #{JRUBY_VERSION}") end end end From 119f37078407530ae3e256f5a5de8c82e582af49 Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Mon, 8 Dec 2025 11:05:41 -0500 Subject: [PATCH 4/8] Readding jruby? --- lib/mongo/server/app_metadata/platform.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/mongo/server/app_metadata/platform.rb b/lib/mongo/server/app_metadata/platform.rb index 42279efcde..a49e0b90bc 100644 --- a/lib/mongo/server/app_metadata/platform.rb +++ b/lib/mongo/server/app_metadata/platform.rb @@ -41,6 +41,13 @@ def ruby? RUBY_ENGINE == 'ruby' end + # Queries whether the current runtime is JRuby or not. + # + # @return [ Boolean ] whether the current runtime is JRuby + def jruby? + RUBY_ENGINE == 'jruby' + end + # Returns the list of Ruby versions that identify this runtime. # # @return [ Array ] the list of ruby versions From 8b796dc5e1f7bb4bfb30080cc79f1ffe71fe2cb9 Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Mon, 8 Dec 2025 12:37:36 -0500 Subject: [PATCH 5/8] Making tests work with capitalization of Ruby --- spec/mongo/client_construction_spec.rb | 2 +- spec/support/shared/app_metadata.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/mongo/client_construction_spec.rb b/spec/mongo/client_construction_spec.rb index 48f4039b4a..079135fcb8 100644 --- a/spec/mongo/client_construction_spec.rb +++ b/spec/mongo/client_construction_spec.rb @@ -960,7 +960,7 @@ let(:platform_string) do [ - "JRuby #{JRUBY_VERSION}", + "jruby #{JRUBY_VERSION}", "like Ruby #{RUBY_VERSION}", RUBY_PLATFORM, "JVM #{java.lang.System.get_property('java.version')}", diff --git a/spec/support/shared/app_metadata.rb b/spec/support/shared/app_metadata.rb index d85cd78ba7..5e5a6f4781 100644 --- a/spec/support/shared/app_metadata.rb +++ b/spec/support/shared/app_metadata.rb @@ -113,7 +113,7 @@ def target_arch it 'adds empty strings' do document[:client][:driver][:name].should == 'mongo-ruby-driver|' document[:client][:driver][:version].should == "#{Mongo::VERSION}|" - document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\z/ + document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\z/ end end @@ -125,7 +125,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid' document[:client][:driver][:version].should == "#{Mongo::VERSION}|" - document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\z/ + document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\z/ end end @@ -137,7 +137,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid' document[:client][:driver][:version].should == "#{Mongo::VERSION}|7.1.2" - document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|OS9000\z/ + document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|OS9000\z/ end end end @@ -156,7 +156,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid|' document[:client][:driver][:version].should == "#{Mongo::VERSION}|42|4.0" - document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\|OS9000\z/ + document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\|OS9000\z/ end end @@ -171,7 +171,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid|Rails' document[:client][:driver][:version].should == "#{Mongo::VERSION}|7.1.2|6.0.3" - document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\|\z/ + document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\|\z/ end end end From 13259defcefc1a1a73593ef3897930810df221bd Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Tue, 9 Dec 2025 10:13:11 -0500 Subject: [PATCH 6/8] Fixing capitalization for engines --- lib/mongo/server/app_metadata/platform.rb | 16 +++++++++++++++- spec/support/shared/app_metadata.rb | 14 +++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/mongo/server/app_metadata/platform.rb b/lib/mongo/server/app_metadata/platform.rb index a49e0b90bc..d882072412 100644 --- a/lib/mongo/server/app_metadata/platform.rb +++ b/lib/mongo/server/app_metadata/platform.rb @@ -48,6 +48,20 @@ def jruby? RUBY_ENGINE == 'jruby' end + # Returns the correct case for known Ruby engines. + # For JRuby, this is 'JRuby'. + # For TruffleRuby, this is 'TruffleRuby'. + def engine_name + case RUBY_ENGINE + when 'jruby' + 'JRuby' + when 'truffleruby' + 'TruffleRuby' + else + RUBY_ENGINE + end + end + # Returns the list of Ruby versions that identify this runtime. # # @return [ Array ] the list of ruby versions @@ -55,7 +69,7 @@ def ruby_versions if ruby? [ "Ruby #{RUBY_VERSION}" ] else - [ "#{RUBY_ENGINE} #{RUBY_ENGINE_VERSION}", "like Ruby #{RUBY_VERSION}" ] + [ "#{engine_name} #{RUBY_ENGINE_VERSION}", "like Ruby #{RUBY_VERSION}" ] end end diff --git a/spec/support/shared/app_metadata.rb b/spec/support/shared/app_metadata.rb index 5e5a6f4781..8f44ac78c7 100644 --- a/spec/support/shared/app_metadata.rb +++ b/spec/support/shared/app_metadata.rb @@ -83,7 +83,7 @@ def target_arch require_jruby it 'includes JRuby and Ruby compatibility versions' do - document[:client][:platform].should start_with("jruby #{JRUBY_VERSION}, like Ruby #{RUBY_VERSION}") + document[:client][:platform].should start_with("JRuby #{JRUBY_VERSION}, like Ruby #{RUBY_VERSION}") end context 'when custom platform is specified' do @@ -92,7 +92,7 @@ def target_arch end it 'starts with custom platform' do - document[:client][:platform].should start_with("foowidgets, jruby #{JRUBY_VERSION}") + document[:client][:platform].should start_with("foowidgets, JRuby #{JRUBY_VERSION}") end end end @@ -113,7 +113,7 @@ def target_arch it 'adds empty strings' do document[:client][:driver][:name].should == 'mongo-ruby-driver|' document[:client][:driver][:version].should == "#{Mongo::VERSION}|" - document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\z/ + document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\z/ end end @@ -125,7 +125,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid' document[:client][:driver][:version].should == "#{Mongo::VERSION}|" - document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\z/ + document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\z/ end end @@ -137,7 +137,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid' document[:client][:driver][:version].should == "#{Mongo::VERSION}|7.1.2" - document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|OS9000\z/ + document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|OS9000\z/ end end end @@ -156,7 +156,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid|' document[:client][:driver][:version].should == "#{Mongo::VERSION}|42|4.0" - document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\|OS9000\z/ + document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\|OS9000\z/ end end @@ -171,7 +171,7 @@ def target_arch it 'adds the fields' do document[:client][:driver][:name].should == 'mongo-ruby-driver|Mongoid|Rails' document[:client][:driver][:version].should == "#{Mongo::VERSION}|7.1.2|6.0.3" - document[:client][:platform].should =~ /\Aj?[Rr]uby[^|]+\|\|\z/ + document[:client][:platform].should =~ /\AJ?Ruby[^|]+\|\|\z/ end end end From f505430d6c794fb0937432e30a3eea8fad48fa5f Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Tue, 9 Dec 2025 11:03:23 -0500 Subject: [PATCH 7/8] Responding to PR comments --- lib/mongo/server/app_metadata/platform.rb | 18 +++++------------- spec/mongo/client_construction_spec.rb | 2 +- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/mongo/server/app_metadata/platform.rb b/lib/mongo/server/app_metadata/platform.rb index d882072412..c009fcec42 100644 --- a/lib/mongo/server/app_metadata/platform.rb +++ b/lib/mongo/server/app_metadata/platform.rb @@ -37,7 +37,7 @@ def initialize(metadata) # Queries whether the current runtime is standard Ruby or not. # # @return [ Boolean ] whether the current runtime is standard Ruby - def ruby? + def mri? RUBY_ENGINE == 'ruby' end @@ -48,25 +48,17 @@ def jruby? RUBY_ENGINE == 'jruby' end - # Returns the correct case for known Ruby engines. - # For JRuby, this is 'JRuby'. - # For TruffleRuby, this is 'TruffleRuby'. + ENGINE_NAMES = { 'jruby' => 'JRuby', 'truffleruby' => 'TruffleRuby' }.freeze + def engine_name - case RUBY_ENGINE - when 'jruby' - 'JRuby' - when 'truffleruby' - 'TruffleRuby' - else - RUBY_ENGINE - end + ENGINE_NAMES[RUBY_ENGINE] || RUBY_ENGINE end # Returns the list of Ruby versions that identify this runtime. # # @return [ Array ] the list of ruby versions def ruby_versions - if ruby? + if mri? [ "Ruby #{RUBY_VERSION}" ] else [ "#{engine_name} #{RUBY_ENGINE_VERSION}", "like Ruby #{RUBY_VERSION}" ] diff --git a/spec/mongo/client_construction_spec.rb b/spec/mongo/client_construction_spec.rb index 079135fcb8..48f4039b4a 100644 --- a/spec/mongo/client_construction_spec.rb +++ b/spec/mongo/client_construction_spec.rb @@ -960,7 +960,7 @@ let(:platform_string) do [ - "jruby #{JRUBY_VERSION}", + "JRuby #{JRUBY_VERSION}", "like Ruby #{RUBY_VERSION}", RUBY_PLATFORM, "JVM #{java.lang.System.get_property('java.version')}", From d6cc4e67146b628be5dd650c35db321926fc2db5 Mon Sep 17 00:00:00 2001 From: Kyle Burgess Date: Tue, 9 Dec 2025 11:06:07 -0500 Subject: [PATCH 8/8] Fixing some typos --- lib/mongo/server/app_metadata/platform.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mongo/server/app_metadata/platform.rb b/lib/mongo/server/app_metadata/platform.rb index c009fcec42..0e77fef5ea 100644 --- a/lib/mongo/server/app_metadata/platform.rb +++ b/lib/mongo/server/app_metadata/platform.rb @@ -34,16 +34,16 @@ def initialize(metadata) @metadata = metadata end - # Queries whether the current runtime is standard Ruby or not. + # Queries whether the current runtime is Ruby MRI or not. # - # @return [ Boolean ] whether the current runtime is standard Ruby + # @return [ true | false ] whether the runtime is Ruby MRI or not. def mri? RUBY_ENGINE == 'ruby' end # Queries whether the current runtime is JRuby or not. # - # @return [ Boolean ] whether the current runtime is JRuby + # @return [ true | false ] whether the runtime is JRuby or not. def jruby? RUBY_ENGINE == 'jruby' end