Skip to content

Commit ed49a89

Browse files
RUBY-3714 Client metadata capture for TruffleRuby (#2971)
* Including ruby engine in metadata in logs * updating comment * changing capitalization of tests to work with new changes * Readding jruby? * Making tests work with capitalization of Ruby * Fixing capitalization for engines * Responding to PR comments * Fixing some typos
1 parent 0462992 commit ed49a89

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/mongo/server/app_metadata/platform.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,34 @@ def initialize(metadata)
3434
@metadata = metadata
3535
end
3636

37+
# Queries whether the current runtime is Ruby MRI or not.
38+
#
39+
# @return [ true | false ] whether the runtime is Ruby MRI or not.
40+
def mri?
41+
RUBY_ENGINE == 'ruby'
42+
end
43+
3744
# Queries whether the current runtime is JRuby or not.
3845
#
3946
# @return [ true | false ] whether the runtime is JRuby or not.
4047
def jruby?
41-
BSON::Environment.jruby?
48+
RUBY_ENGINE == 'jruby'
49+
end
50+
51+
ENGINE_NAMES = { 'jruby' => 'JRuby', 'truffleruby' => 'TruffleRuby' }.freeze
52+
53+
def engine_name
54+
ENGINE_NAMES[RUBY_ENGINE] || RUBY_ENGINE
4255
end
4356

4457
# Returns the list of Ruby versions that identify this runtime.
4558
#
4659
# @return [ Array<String> ] the list of ruby versions
4760
def ruby_versions
48-
if jruby?
49-
[ "JRuby #{JRUBY_VERSION}", "like Ruby #{RUBY_VERSION}" ]
50-
else
61+
if mri?
5162
[ "Ruby #{RUBY_VERSION}" ]
63+
else
64+
[ "#{engine_name} #{RUBY_ENGINE_VERSION}", "like Ruby #{RUBY_VERSION}" ]
5265
end
5366
end
5467

0 commit comments

Comments
 (0)