From fd88fd8a05efdaafa2c631315f88c0bd841b0ac5 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Mon, 28 Mar 2022 13:32:05 +0000 Subject: [PATCH] feat: RubyGems Fallback 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()` where possible. See https://github.com/open-telemetry/opentelemetry-ruby/issues/947 Related https://github.com/open-telemetry/opentelemetry-ruby/issues/988#issuecomment-1018676853 --- .../action_pack/gemfiles/rails_7.0.gemfile | 2 +- .../action_pack/instrumentation.rb | 2 +- .../action_view/gemfiles/rails_5.2.gemfile | 1 + .../action_view/gemfiles/rails_6.0.gemfile | 1 + .../action_view/gemfiles/rails_6.1.gemfile | 1 + .../action_view/gemfiles/rails_7.0.gemfile | 3 ++- .../action_view/instrumentation.rb | 6 +++++- .../active_job/gemfiles/activejob_5.2.gemfile | 3 +-- .../active_job/gemfiles/activejob_6.0.gemfile | 3 +-- .../active_job/gemfiles/activejob_6.1.gemfile | 3 +-- .../active_job/gemfiles/rails_7.0.gemfile | 15 +++++++++++++++ .../active_job/instrumentation.rb | 6 +++++- .../active_model_serializers_0.10.gemfile | 5 ++++- .../instrumentation.rb | 2 +- .../active_record/instrumentation.rb | 2 +- .../aws_sdk/gemfiles/aws_sdk_2.0.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.1.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.10.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.11.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.2.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.3.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.4.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.5.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.6.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.7.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.8.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_2.9.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_3.0.gemfile | 1 + .../aws_sdk/gemfiles/aws_sdk_3.1.gemfile | 1 + .../aws_sdk/instrumentation.rb | 6 +----- .../lib/opentelemetry/instrumentation/base.rb | 2 +- .../delayed_job/instrumentation.rb | 2 ++ .../http/gemfiles/http_3.3.0.gemfile | 2 ++ .../http/gemfiles/http_4.4.gemfile | 2 ++ .../instrumentation/http/instrumentation.rb | 2 +- .../http/instrumentation_test.rb | 5 ----- .../mongo/gemfiles/mongo_2.13.gemfile | 5 ++++- .../instrumentation/mongo/instrumentation.rb | 2 +- instrumentation/pg/gemfiles/pg_1.2.3.gemfile | 3 +++ .../instrumentation/pg/instrumentation.rb | 4 ++++ instrumentation/que/gemfiles/que_1.0.gemfile | 5 ++++- .../instrumentation/que/instrumentation.rb | 2 +- .../gemfiles/ruby_kafka_0.7.0.gemfile | 18 ++++++++++++++++++ .../gemfiles/ruby_kafka_1.0.0.gemfile | 3 +++ .../gemfiles/ruby_kafka_1.1.0.gemfile | 3 +++ .../gemfiles/ruby_kafka_1.2.0.gemfile | 3 +++ .../gemfiles/ruby_kafka_1.3.0.gemfile | 3 +++ .../sidekiq/gemfiles/sidekiq_4.2.gemfile | 3 +++ .../sidekiq/gemfiles/sidekiq_5.2.gemfile | 3 +++ .../sidekiq/gemfiles/sidekiq_6.0.gemfile | 3 +++ .../sidekiq/gemfiles/sidekiq_6.1.gemfile | 3 +++ .../sidekiq/gemfiles/sidekiq_6.3.gemfile | 19 +++++++++++++++++++ .../sidekiq/instrumentation.rb | 2 +- 53 files changed, 143 insertions(+), 31 deletions(-) create mode 100644 instrumentation/active_job/gemfiles/rails_7.0.gemfile create mode 100644 instrumentation/ruby_kafka/gemfiles/ruby_kafka_0.7.0.gemfile create mode 100644 instrumentation/sidekiq/gemfiles/sidekiq_6.3.gemfile diff --git a/instrumentation/action_pack/gemfiles/rails_7.0.gemfile b/instrumentation/action_pack/gemfiles/rails_7.0.gemfile index 5efefeecb7..3d5400e370 100644 --- a/instrumentation/action_pack/gemfiles/rails_7.0.gemfile +++ b/instrumentation/action_pack/gemfiles/rails_7.0.gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" -gem "rails", "~> 7.0.0.alpha2" +gem "rails", "~> 7.0.0" group :test do gem "byebug" diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb index 4d0afc8cf5..3e1341c480 100644 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb +++ b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb @@ -30,7 +30,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private def gem_version - Gem.loaded_specs['actionpack'].version + Gem.loaded_specs['actionpack']&.version || ::ActionPack.version end def patch diff --git a/instrumentation/action_view/gemfiles/rails_5.2.gemfile b/instrumentation/action_view/gemfiles/rails_5.2.gemfile index 0012175584..7cd875c679 100644 --- a/instrumentation/action_view/gemfiles/rails_5.2.gemfile +++ b/instrumentation/action_view/gemfiles/rails_5.2.gemfile @@ -9,6 +9,7 @@ gem "rails", "~> 5.2.0" group :test do gem "byebug" gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-instrumentation-active_support", path: "../../../instrumentation/active_support" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" diff --git a/instrumentation/action_view/gemfiles/rails_6.0.gemfile b/instrumentation/action_view/gemfiles/rails_6.0.gemfile index b7b20e8fe1..6a6d06b68d 100644 --- a/instrumentation/action_view/gemfiles/rails_6.0.gemfile +++ b/instrumentation/action_view/gemfiles/rails_6.0.gemfile @@ -9,6 +9,7 @@ gem "rails", "~> 6.0.0" group :test do gem "byebug" gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-instrumentation-active_support", path: "../../../instrumentation/active_support" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" diff --git a/instrumentation/action_view/gemfiles/rails_6.1.gemfile b/instrumentation/action_view/gemfiles/rails_6.1.gemfile index 9fb4b4a3f1..3b6c6d3527 100644 --- a/instrumentation/action_view/gemfiles/rails_6.1.gemfile +++ b/instrumentation/action_view/gemfiles/rails_6.1.gemfile @@ -9,6 +9,7 @@ gem "rails", "~> 6.1.0" group :test do gem "byebug" gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-instrumentation-active_support", path: "../../../instrumentation/active_support" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" diff --git a/instrumentation/action_view/gemfiles/rails_7.0.gemfile b/instrumentation/action_view/gemfiles/rails_7.0.gemfile index ec41836e0f..6d42276b9a 100644 --- a/instrumentation/action_view/gemfiles/rails_7.0.gemfile +++ b/instrumentation/action_view/gemfiles/rails_7.0.gemfile @@ -4,11 +4,12 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" gem "opentelemetry-instrumentation-base", path: "../../base" -gem "rails", "~> 7.0.0.alpha2" +gem "rails", "~> 7.0.0" group :test do gem "byebug" gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-instrumentation-active_support", path: "../../../instrumentation/active_support" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb index af17c510d0..0dcab4a522 100644 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb +++ b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/instrumentation.rb @@ -19,7 +19,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base end compatible do - Gem.loaded_specs['actionview'].version >= MINIMUM_VERSION + gem_version >= MINIMUM_VERSION end option :disallowed_notification_payload_keys, default: [], validate: :array @@ -27,6 +27,10 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private + def gem_version + Gem.loaded_specs['actionview'].version || ::ActionView.version + end + def require_dependencies require_relative 'railtie' end diff --git a/instrumentation/active_job/gemfiles/activejob_5.2.gemfile b/instrumentation/active_job/gemfiles/activejob_5.2.gemfile index acaad17240..cdecec0142 100644 --- a/instrumentation/active_job/gemfiles/activejob_5.2.gemfile +++ b/instrumentation/active_job/gemfiles/activejob_5.2.gemfile @@ -9,8 +9,7 @@ gem "activejob", "~> 5.2.0" group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" - gem "pry" - gem "pry-byebug" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" end gemspec path: "../" diff --git a/instrumentation/active_job/gemfiles/activejob_6.0.gemfile b/instrumentation/active_job/gemfiles/activejob_6.0.gemfile index ae0d0948f0..eef9507cdb 100644 --- a/instrumentation/active_job/gemfiles/activejob_6.0.gemfile +++ b/instrumentation/active_job/gemfiles/activejob_6.0.gemfile @@ -9,8 +9,7 @@ gem "activejob", "~> 6.0.0" group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" - gem "pry" - gem "pry-byebug" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" end gemspec path: "../" diff --git a/instrumentation/active_job/gemfiles/activejob_6.1.gemfile b/instrumentation/active_job/gemfiles/activejob_6.1.gemfile index 4f105aa7dd..c3af4c7e0f 100644 --- a/instrumentation/active_job/gemfiles/activejob_6.1.gemfile +++ b/instrumentation/active_job/gemfiles/activejob_6.1.gemfile @@ -9,8 +9,7 @@ gem "activejob", "~> 6.1.0" group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" - gem "pry" - gem "pry-byebug" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" end gemspec path: "../" diff --git a/instrumentation/active_job/gemfiles/rails_7.0.gemfile b/instrumentation/active_job/gemfiles/rails_7.0.gemfile new file mode 100644 index 0000000000..e3aa7ff360 --- /dev/null +++ b/instrumentation/active_job/gemfiles/rails_7.0.gemfile @@ -0,0 +1,15 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" +gem "rails", "~> 7.0.0" + +group :test do + gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" +end + +gemspec path: "../" diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb index 3332e6cff4..156b540e3b 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb @@ -21,7 +21,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base end compatible do - Gem.loaded_specs['activejob'].version >= MINIMUM_VERSION + gem_version >= MINIMUM_VERSION end ## Supported configuration keys for the install config hash: @@ -58,6 +58,10 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private + def gem_version + Gem.loaded_specs['activejob']&.version || ::ActiveJob.version + end + def require_dependencies require_relative 'patches/base' require_relative 'patches/active_job_callbacks' diff --git a/instrumentation/active_model_serializers/gemfiles/active_model_serializers_0.10.gemfile b/instrumentation/active_model_serializers/gemfiles/active_model_serializers_0.10.gemfile index 411d5c1935..66c2a0b847 100644 --- a/instrumentation/active_model_serializers/gemfiles/active_model_serializers_0.10.gemfile +++ b/instrumentation/active_model_serializers/gemfiles/active_model_serializers_0.10.gemfile @@ -3,10 +3,13 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" -gem "active_model_serializers", "~> 0.10.10" +gem "opentelemetry-instrumentation-base", path: "../../base" +gem "active_model_serializers", "~> 0.10.0" group :test do + gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" end gemspec path: "../" diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb index c04bd97b2c..a024fc088e 100644 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb +++ b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb @@ -27,7 +27,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private def gem_version - Gem.loaded_specs['active_model_serializers'].version + Gem.loaded_specs['active_model_serializers']&.version || Gem::Version.new(::ActiveModel::Serializer::VERSION) end def require_dependencies diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb index 8d60c53d2a..0369b76a3e 100644 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb +++ b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/instrumentation.rb @@ -36,7 +36,7 @@ def insert_class_methods_supported? end def gem_version - Gem.loaded_specs['activerecord'].version + Gem.loaded_specs['activerecord']&.version || ::ActiveRecord.version end def patch diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.0.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.0.gemfile index cef49f2c29..15f3b83318 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.0.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.0.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.1.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.1.gemfile index db21a781e5..2c0fc2d7de 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.1.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.1.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.10.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.10.gemfile index dee32c620b..c58dc690c7 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.10.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.10.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.11.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.11.gemfile index 04384fcc4e..9770476935 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.11.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.11.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.2.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.2.gemfile index ce98b33a09..af6135ef59 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.2.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.2.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.3.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.3.gemfile index a0d81a8f2d..6daf221999 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.3.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.3.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.4.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.4.gemfile index b0de2baacc..6e1b971dc9 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.4.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.4.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.5.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.5.gemfile index 8a49c3204f..6010c7cfa9 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.5.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.5.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.6.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.6.gemfile index e3365f534b..6be80b5e76 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.6.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.6.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.7.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.7.gemfile index 2c8fe52a9c..7bfcae33a5 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.7.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.7.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.8.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.8.gemfile index ed1eb523c3..06d948d06d 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.8.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.8.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.9.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.9.gemfile index 66071d6977..c1c5abf44a 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_2.9.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_2.9.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_3.0.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_3.0.gemfile index 0719f5fd91..c26893d3b3 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_3.0.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_3.0.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/gemfiles/aws_sdk_3.1.gemfile b/instrumentation/aws_sdk/gemfiles/aws_sdk_3.1.gemfile index 884b1f6f49..f2b83e8bb4 100644 --- a/instrumentation/aws_sdk/gemfiles/aws_sdk_3.1.gemfile +++ b/instrumentation/aws_sdk/gemfiles/aws_sdk_3.1.gemfile @@ -10,6 +10,7 @@ group :test do gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "webrick", "~> 1.7" end gemspec path: "../" diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb index 640ebb4bc9..b163d01f5f 100644 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb +++ b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb @@ -28,11 +28,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base option :suppress_internal_instrumentation, default: false, validate: :boolean def gem_version - if Gem.loaded_specs['aws-sdk'] - Gem.loaded_specs['aws-sdk'].version - elsif Gem.loaded_specs['aws-sdk-core'] - Gem.loaded_specs['aws-sdk-core'].version - end + Gem.loaded_specs['aws-sdk']&.version || Gem.loaded_specs['aws-sdk-core']&.version || Gem::Version.new(::Aws::CORE_GEM_VERSION) end private diff --git a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb b/instrumentation/base/lib/opentelemetry/instrumentation/base.rb index 582c962717..af1d7f8874 100644 --- a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb +++ b/instrumentation/base/lib/opentelemetry/instrumentation/base.rb @@ -32,7 +32,7 @@ module Instrumentation # # # if the target library is present, is it compatible? # compatible do - # Gem.loaded_specs['sinatra'].version > MIN_VERSION + # (Gem.loaded_specs['sinatra']&.version || Gem::Version.new(Sinatra::VERSION)) > MIN_VERSION # end # end # end diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb index 07a6d43162..d6b4368a64 100644 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb +++ b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/instrumentation.rb @@ -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 end diff --git a/instrumentation/http/gemfiles/http_3.3.0.gemfile b/instrumentation/http/gemfiles/http_3.3.0.gemfile index d37e0951cd..b4349f5476 100644 --- a/instrumentation/http/gemfiles/http_3.3.0.gemfile +++ b/instrumentation/http/gemfiles/http_3.3.0.gemfile @@ -3,12 +3,14 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "http", "~> 3.3.0" group :test do gem "byebug" gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" end diff --git a/instrumentation/http/gemfiles/http_4.4.gemfile b/instrumentation/http/gemfiles/http_4.4.gemfile index 2e4eb6fc56..700a80d327 100644 --- a/instrumentation/http/gemfiles/http_4.4.gemfile +++ b/instrumentation/http/gemfiles/http_4.4.gemfile @@ -3,12 +3,14 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "http", "~> 4.4.0" group :test do gem "byebug" gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" end diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb index d41e1b5f67..3fb03fb0ad 100644 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb +++ b/instrumentation/http/lib/opentelemetry/instrumentation/http/instrumentation.rb @@ -15,7 +15,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base end present do - !(defined?(::HTTP) && Gem.loaded_specs['http']).nil? + !(defined?(::HTTP::Client).nil? || defined?(::HTTP::Connection).nil?) end def patch diff --git a/instrumentation/http/test/instrumentation/http/instrumentation_test.rb b/instrumentation/http/test/instrumentation/http/instrumentation_test.rb index 259eac1185..302ac483d4 100644 --- a/instrumentation/http/test/instrumentation/http/instrumentation_test.rb +++ b/instrumentation/http/test/instrumentation/http/instrumentation_test.rb @@ -29,11 +29,6 @@ hide_const('HTTP') _(instrumentation.present?).must_equal(false) end - - it 'when http gem not installed' do - allow(Gem).to receive(:loaded_specs).and_return({}) - _(instrumentation.present?).must_equal(false) - end end describe '#install' do diff --git a/instrumentation/mongo/gemfiles/mongo_2.13.gemfile b/instrumentation/mongo/gemfiles/mongo_2.13.gemfile index 306505d544..95c194f3fd 100644 --- a/instrumentation/mongo/gemfiles/mongo_2.13.gemfile +++ b/instrumentation/mongo/gemfiles/mongo_2.13.gemfile @@ -3,10 +3,13 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" -gem "mongo-ruby-driver", "~> 2.13.0" +gem "opentelemetry-instrumentation-base", path: "../../base" +gem "mongo", "~> 2.13.0" group :test do + gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" end gemspec path: "../" diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb index 5991a4577c..ec3fb6348b 100644 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb +++ b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/instrumentation.rb @@ -30,7 +30,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private def gem_version - Gem.loaded_specs['mongo']&.version + Gem.loaded_specs['mongo']&.version || Gem::Version.new(::Mongo::VERSION) end def require_dependencies diff --git a/instrumentation/pg/gemfiles/pg_1.2.3.gemfile b/instrumentation/pg/gemfiles/pg_1.2.3.gemfile index ab1d2d3cfd..804cddf0e5 100644 --- a/instrumentation/pg/gemfiles/pg_1.2.3.gemfile +++ b/instrumentation/pg/gemfiles/pg_1.2.3.gemfile @@ -3,10 +3,13 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "pg" group :test do + gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" end gemspec path: "../" diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb index cb37810a57..0f7af067ca 100644 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb +++ b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb @@ -47,6 +47,10 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private + def gem_version + Gem.loaded_specs['pg']&.version || Gem::Version.new(::PG::VERSION) + end + def require_dependencies require_relative 'patches/connection' end diff --git a/instrumentation/que/gemfiles/que_1.0.gemfile b/instrumentation/que/gemfiles/que_1.0.gemfile index 38ce00e0a9..e8bcf8a8ad 100644 --- a/instrumentation/que/gemfiles/que_1.0.gemfile +++ b/instrumentation/que/gemfiles/que_1.0.gemfile @@ -3,11 +3,14 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" -gem "que", "~> 1.0.0.beta4" +gem "opentelemetry-instrumentation-base", path: "../../base" +gem "que", "1.0.0.beta4" group :test do gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-instrumentation-pg", path: "../../../instrumentation/pg" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" end gemspec path: "../" diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb index 7f0d840f26..c32209ebd5 100644 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb +++ b/instrumentation/que/lib/opentelemetry/instrumentation/que/instrumentation.rb @@ -58,7 +58,7 @@ def require_dependencies end def gem_version - Gem.loaded_specs['que'].version + Gem.loaded_specs['que']&.version || Gem::Version.new(::Que::VERSION) end def patch diff --git a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_0.7.0.gemfile b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_0.7.0.gemfile new file mode 100644 index 0000000000..d9bc83d7b8 --- /dev/null +++ b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_0.7.0.gemfile @@ -0,0 +1,18 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" +gem "ruby-kafka", "~> 0.7.0" + +group :test do + gem "activesupport" + gem "byebug" + gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "pry-byebug" +end + +gemspec path: "../" diff --git a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.0.0.gemfile b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.0.0.gemfile index b0e290cc7a..e1c330aaba 100644 --- a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.0.0.gemfile +++ b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.0.0.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "ruby-kafka", "~> 1.0.0" group :test do gem "activesupport" gem "byebug" + gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" end diff --git a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.1.0.gemfile b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.1.0.gemfile index 4cb1042dca..55e3f6b6b3 100644 --- a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.1.0.gemfile +++ b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.1.0.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "ruby-kafka", "~> 1.1.0" group :test do gem "activesupport" gem "byebug" + gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" end diff --git a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.2.0.gemfile b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.2.0.gemfile index 08f8564374..eacb9e65c4 100644 --- a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.2.0.gemfile +++ b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.2.0.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "ruby-kafka", "~> 1.2.0" group :test do gem "activesupport" gem "byebug" + gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" end diff --git a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.3.0.gemfile b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.3.0.gemfile index e1ebb0be5d..2f10166894 100644 --- a/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.3.0.gemfile +++ b/instrumentation/ruby_kafka/gemfiles/ruby_kafka_1.3.0.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "ruby-kafka", "~> 1.3.0" group :test do gem "activesupport" gem "byebug" + gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry-byebug" end diff --git a/instrumentation/sidekiq/gemfiles/sidekiq_4.2.gemfile b/instrumentation/sidekiq/gemfiles/sidekiq_4.2.gemfile index 7737ebac50..88c55338f4 100644 --- a/instrumentation/sidekiq/gemfiles/sidekiq_4.2.gemfile +++ b/instrumentation/sidekiq/gemfiles/sidekiq_4.2.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "sidekiq", "~> 4.2" group :test do + gem "activejob" gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-instrumentation-redis", path: "../../redis" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry" gem "pry-byebug" end diff --git a/instrumentation/sidekiq/gemfiles/sidekiq_5.2.gemfile b/instrumentation/sidekiq/gemfiles/sidekiq_5.2.gemfile index 4765fd6775..a74eaaf753 100644 --- a/instrumentation/sidekiq/gemfiles/sidekiq_5.2.gemfile +++ b/instrumentation/sidekiq/gemfiles/sidekiq_5.2.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "sidekiq", "~> 5.2" group :test do + gem "activejob" gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-instrumentation-redis", path: "../../redis" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry" gem "pry-byebug" end diff --git a/instrumentation/sidekiq/gemfiles/sidekiq_6.0.gemfile b/instrumentation/sidekiq/gemfiles/sidekiq_6.0.gemfile index 6e9151a887..7e9ec56bf4 100644 --- a/instrumentation/sidekiq/gemfiles/sidekiq_6.0.gemfile +++ b/instrumentation/sidekiq/gemfiles/sidekiq_6.0.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "sidekiq", "~> 6.0" group :test do + gem "activejob" gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-instrumentation-redis", path: "../../redis" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry" gem "pry-byebug" end diff --git a/instrumentation/sidekiq/gemfiles/sidekiq_6.1.gemfile b/instrumentation/sidekiq/gemfiles/sidekiq_6.1.gemfile index a92717f87c..cd74a6158b 100644 --- a/instrumentation/sidekiq/gemfiles/sidekiq_6.1.gemfile +++ b/instrumentation/sidekiq/gemfiles/sidekiq_6.1.gemfile @@ -3,12 +3,15 @@ source "https://rubygems.org" gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" gem "sidekiq", "~> 6.1" group :test do + gem "activejob" gem "opentelemetry-common", path: "../../../common" gem "opentelemetry-instrumentation-redis", path: "../../redis" gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" gem "pry" gem "pry-byebug" end diff --git a/instrumentation/sidekiq/gemfiles/sidekiq_6.3.gemfile b/instrumentation/sidekiq/gemfiles/sidekiq_6.3.gemfile new file mode 100644 index 0000000000..b810975913 --- /dev/null +++ b/instrumentation/sidekiq/gemfiles/sidekiq_6.3.gemfile @@ -0,0 +1,19 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "opentelemetry-api", path: "../../../api" +gem "opentelemetry-instrumentation-base", path: "../../base" +gem "sidekiq", "~> 6.3" + +group :test do + gem "activejob" + gem "opentelemetry-common", path: "../../../common" + gem "opentelemetry-instrumentation-redis", path: "../../redis" + gem "opentelemetry-sdk", path: "../../../sdk" + gem "opentelemetry-semantic_conventions", path: "../../../semantic_conventions" + gem "pry" + gem "pry-byebug" +end + +gemspec path: "../" diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb index b95976bc0f..a275f422ac 100644 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb +++ b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb @@ -38,7 +38,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private def gem_version - Gem.loaded_specs['sidekiq'].version + Gem.loaded_specs['sidekiq']&.version || Gem::Version.new(::Sidekiq::VERSION) end def require_dependencies