-
Notifications
You must be signed in to change notification settings - Fork 248
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
fix: RubyGems Fallback #1161
fix: RubyGems Fallback #1161
Conversation
5cb7fc6
to
0ed52f7
Compare
Summarizing our conversation on 2022-03-29 we prefer to rely on gem specific constants over |
@@ -27,6 +27,8 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base | |||
private | |||
|
|||
def gem_version | |||
# Version is hardcoded in the gemspec | |||
# https://github.com/collectiveidea/delayed_job/blob/master/delayed_job.gemspec#L16 | |||
Gem.loaded_specs['delayed_job'].version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we want to rub some try (&.
) on this? Or leave as-is for an exception instead of a nil?
Or maybe …
Gem.loaded_specs['delayed_job'].version | |
Gem.loaded_specs.fetch('delayed_job').version |
… for a different exception? KeyError (key not found: "delayed_job")
as opposed to NoMethodError (undefined method 'version' for nil:NilClass)
(I am indeed trying to make fetch
happen.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even …
Gem.loaded_specs['delayed_job'].version | |
Gem | |
.loaded_specs | |
.fetch('delayed_job') { raise KeyError.new("'delayed_job' not | |
found among Gem.loaded_specs") } | |
.version |
… for KeyError ('delayed_job' not found among Gem.loaded_specs)
.
🤔 Maybe that's too much fetch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would trigger the error_handler
, is that how we want to control the flow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's how flow is controlled with the existing implementation.
Gem.loaded_specs['delayed_job'].version
If it can't find 'delayed_job'
in Gem.loaded_specs
, aNoMethodError (undefined method 'version' for nil:NilClass)
exception would be thrown (right?) which I think is less clear about what the true error is.
Update: yep.
irb(main):001:0> Gem.loaded_specs['no_such_gem'].version
Traceback (most recent call last):
… blah blah blah
NoMethodError (undefined method `version' for nil:NilClass)
irb(main):002:0> Gem.loaded_specs.fetch('no_such_gem'){raise KeyError.new("'no_such_gem' not found among Gem.loaded_specs")}.version
Traceback (most recent call last):
… blah blah blah
KeyError ('no_such_gem' not found among Gem.loaded_specs)
0fbb507
to
28c7cbb
Compare
Got a failing test for AWS v2.11 after removing mocks/stubs in my last commit. @NathanielRN does the SDK team have a Timeline for EoL since v2 is deprecated? |
NVM @NathanielRN I read STDERR
|
@YanivD I am going to drop support for AWS SDK 2.0 since it is no longer under maintenance since 2021-11. I will open a separate PR. Please let me know if you have any concerns. |
cc: #1166 |
258198d
to
689d7db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The GitHub Monolith bypasses RubyGems when loading dependencies, which results in a `nil` variable being returned by `Gem.loaded_specs`. This change fallsback to using `Gem::Version.new(<VERSION>)` where possible. See open-telemetry#947 Related https://github.com/open-telemetry/opentelemetry-ruby/issues/988#issuecomment-1018676853
Prior to this commit developers had to either run tests from within a container, or independently run services from their host machine. Developers may now use docker-compose for all services and run tests from their host machine.
d31b2ed
to
4fb6b66
Compare
Two unexpected errors in the test suites suite Ruby 2.5 https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true The Gemfile's dependencies are satisfied
[4972](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4972)
opentelemetry-instrumentation-rdkafka: test
[4973](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4973)
Your RubyGems version (2.7.6.3) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system 3.2.3`
[4974](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4974)
>> BUNDLE_GEMFILE=/home/runner/work/opentelemetry-ruby/opentelemetry-ruby/instrumentation/rdkafka/gemfiles/rdkafka_0.10.0.gemfile bundle exec rake test
[4975](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4975)
Your RubyGems version (2.7.6.3) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system 3.2.3`
[4976](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4976)
Run options: --seed 8271
[4977](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4977)
[4978](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4978)
# Running:
[4979](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4979)
[4980](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4980)
......
[4981](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4981)
[4982](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4982)
Finished in 11.175682s, 0.5369 runs/s, 3.1318 assertions/s.
[4983](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4983)
[4984](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4984)
6 runs, 35 assertions, 0 failures, 0 errors, 0 skips
[4985](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4985)
Segmentation fault (core dumped)
[4986](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4986)
rake aborted!
[4987](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4987)
Command failed with status (139)
[4988](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4988)
/opt/hostedtoolcache/Ruby/2.5.9/x64/bin/bundle:23:in `load'
[4989](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4989)
/opt/hostedtoolcache/Ruby/2.5.9/x64/bin/bundle:23:in `<main>'
[4990](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4990)
Tasks: TOP => test
[4991](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998961?check_suite_focus=true#step:6:4991)
(See full trace by running task with --trace) Ruby 2.6 https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true # Running:
[994](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:994)
[995](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:995)
.......................................F..
[996](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:996)
[997](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:997)
Finished in 0.044692s, 939.7698 runs/s, 2080.9188 assertions/s.
[998](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:998)
[999](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:999)
1) Failure:
[1000](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1000)
OpenTelemetry::Instrumentation::ActiveJob::Patches::ActiveJobCallbacks::attributes::messaging.active_job.executions#test_0002_tracks correctly for jobs that do retry [/home/runner/work/opentelemetry-ruby/opentelemetry-ruby/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb:218]:
[1001](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1001)
Expected: 2
[1002](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1002)
Actual: 1
[1003](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1003)
[1004](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1004)
42 runs, 93 assertions, 1 failures, 0 errors, 0 skips
[1005](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1005)
rake aborted!
[1006](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1006)
Command failed with status (1)
[1007](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1007)
/opt/hostedtoolcache/Ruby/2.6.9/x64/bin/bundle:23:in `load'
[1008](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1008)
/opt/hostedtoolcache/Ruby/2.6.9/x64/bin/bundle:23:in `<main>'
[1009](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1009)
Tasks: TOP => test
[1010](https://github.com/open-telemetry/opentelemetry-ruby/runs/5799998978?check_suite_focus=true#step:6:1010)
(See full trace by running task with --trace) |
@open-telemetry/ruby-maintainers thoughts? |
@arielvalentin the tests appear to have magically fixed themselves, fwiw. |
The GitHub Monolith bypasses RubyGems when loading dependencies, which results in a
nil
variable being returned byGem.loaded_specs
.This change fallsback to using
Gem::Version.new(<VERSION>)
where possible.See #947
Related open-telemetry/opentelemetry-ruby-contrib#373