diff --git a/.github/actions/test_gem/action.yml b/.github/actions/test_gem/action.yml index 0d4feddb8..d68836326 100644 --- a/.github/actions/test_gem/action.yml +++ b/.github/actions/test_gem/action.yml @@ -95,6 +95,7 @@ runs: run: | # 💎 Install dependencies and generate appraisals 💎 bundle install --quiet --jobs=3 --retry=4 + bundle exec appraisal clean bundle exec appraisal generate working-directory: "${{ steps.setup.outputs.gem_dir }}" diff --git a/.gitignore b/.gitignore index a14376cfb..616fb0f93 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ # Appraisals instrumentation/**/gemfiles +instrumentation/**/tmp/**/* # Sqlite file for tests instrumentation/active_record/db @@ -26,3 +27,4 @@ instrumentation/active_record/db .ruby-version tags +!**/*/.gitkeep diff --git a/instrumentation/action_mailer/Appraisals b/instrumentation/action_mailer/Appraisals index e6c48d017..bd32cbe25 100644 --- a/instrumentation/action_mailer/Appraisals +++ b/instrumentation/action_mailer/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "action_mailer-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "action_mailer-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'action_mailer-latest' do + gem 'rails' end end diff --git a/instrumentation/action_pack/Appraisals b/instrumentation/action_pack/Appraisals index e6c48d017..2f466100e 100644 --- a/instrumentation/action_pack/Appraisals +++ b/instrumentation/action_pack/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'rails-latest' do + gem 'rails' end end diff --git a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb b/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb index 00433df24..bec7648c5 100644 --- a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb +++ b/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb @@ -16,7 +16,7 @@ let(:exporter) { EXPORTER } let(:spans) { exporter.finished_spans } let(:span) { exporter.finished_spans.last } - let(:rails_app) { DEFAULT_RAILS_APP } + let(:rails_app) { AppConfig.initialize_app } let(:config) { {} } # Clear captured spans diff --git a/instrumentation/action_pack/test/test_helper.rb b/instrumentation/action_pack/test/test_helper.rb index 4405450bc..c6ad0deee 100644 --- a/instrumentation/action_pack/test/test_helper.rb +++ b/instrumentation/action_pack/test/test_helper.rb @@ -22,8 +22,3 @@ c.use 'OpenTelemetry::Instrumentation::ActionPack' c.add_span_processor span_processor end - -# Create a globally available Rails app, this should be used in test unless -# specifically testing behaviour with different initialization configs. -DEFAULT_RAILS_APP = AppConfig.initialize_app -Rails.application = DEFAULT_RAILS_APP diff --git a/instrumentation/action_pack/test/test_helpers/app_config.rb b/instrumentation/action_pack/test/test_helpers/app_config.rb index f00733ad4..ce0f7ff6d 100644 --- a/instrumentation/action_pack/test/test_helpers/app_config.rb +++ b/instrumentation/action_pack/test/test_helpers/app_config.rb @@ -4,8 +4,8 @@ # # SPDX-License-Identifier: Apache-2.0 -class Application < Rails::Application; end require 'action_controller/railtie' +class Application < Rails::Application; end require_relative 'middlewares' require_relative 'controllers' require_relative 'routes' @@ -30,7 +30,7 @@ def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: fal case Rails.version when /^6\.1/ apply_rails_6_1_configs(new_app) - when /^7\./ + when /^7|8\./ apply_rails_7_configs(new_app) end diff --git a/instrumentation/action_view/Appraisals b/instrumentation/action_view/Appraisals index e6c48d017..76b37a422 100644 --- a/instrumentation/action_view/Appraisals +++ b/instrumentation/action_view/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "action_view-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'rails-latest' do + gem 'rails' end end diff --git a/instrumentation/active_job/Appraisals b/instrumentation/active_job/Appraisals index a25edd334..6d4d4dc42 100644 --- a/instrumentation/active_job/Appraisals +++ b/instrumentation/active_job/Appraisals @@ -10,6 +10,14 @@ end end -appraise 'activejob-latest' do - gem 'activejob' +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + %w[7.2.0].each do |version| + appraise "activejob-#{version}" do + gem 'activejob', "~> #{version}" + end + end + + appraise 'activejob-latest' do + gem 'activejob' + end end diff --git a/instrumentation/active_record/Appraisals b/instrumentation/active_record/Appraisals index 36f641b64..faa0add16 100644 --- a/instrumentation/active_record/Appraisals +++ b/instrumentation/active_record/Appraisals @@ -4,20 +4,23 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'activerecord-6.1' do - gem 'activerecord', '~> 6.1.0' -end - -appraise 'activerecord-7.0' do - gem 'activerecord', '~> 7.0.0' -end - -appraise 'activerecord-7.1' do - gem 'activerecord', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "activerecord-#{version}" do + gem 'sqlite3', '~> 1.4' + gem 'activerecord', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'activerecord-7.2' do - gem 'activerecord', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "activerecord-#{version}" do + gem 'sqlite3', '~> 1.4' + gem 'activerecord', "~> #{version}" + end + end + + appraise 'activerecord-latest' do + gem 'sqlite3', '>= 2.1' + gem 'activerecord' end end diff --git a/instrumentation/active_record/Gemfile b/instrumentation/active_record/Gemfile index 4475d27bf..02f64ca9a 100644 --- a/instrumentation/active_record/Gemfile +++ b/instrumentation/active_record/Gemfile @@ -12,5 +12,4 @@ group :test do gem 'byebug' gem 'opentelemetry-instrumentation-base', path: '../base' gem 'pry-byebug' - gem 'sqlite3', '~> 1.4' end diff --git a/instrumentation/active_support/Appraisals b/instrumentation/active_support/Appraisals index ef832823b..3a6dfc3fe 100644 --- a/instrumentation/active_support/Appraisals +++ b/instrumentation/active_support/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'activesupport-6.1' do - gem 'activesupport', '~> 6.1.0' -end - -appraise 'activesupport-7.0' do - gem 'activesupport', '~> 7.0.0' -end - -appraise 'activesupport-7.1' do - gem 'activesupport', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "activesupport-#{version}" do + gem 'activesupport', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'activesupport-7.2' do - gem 'activesupport', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "activesupport-#{version}" do + gem 'activesupport', "~> #{version}" + end + end + + appraise 'activesupport-latest' do + gem 'activesupport' end end diff --git a/instrumentation/delayed_job/Appraisals b/instrumentation/delayed_job/Appraisals index e4d86e84f..9099f1369 100644 --- a/instrumentation/delayed_job/Appraisals +++ b/instrumentation/delayed_job/Appraisals @@ -4,18 +4,23 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'delayed_job_4.1-rails-latest' do - gem 'activejob' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "delayed_job_4.1-activejob-#{version}" do + gem 'delayed_job', '~> 4.1' + gem 'activejob', "~> #{version}" + end end -appraise 'delayed_job_4.1-rails-7.1' do - gem 'activejob', '~> 7.1.0' -end - -appraise 'delayed_job_4.1-rails-7.0' do - gem 'activejob', '~> 7.0.0' -end +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + %w[7.2.0].each do |version| + appraise "delayed_job-4.1-activejob-#{version}" do + gem 'delayed_job', '~> 4.1' + gem 'activejob', "~> #{version}" + end + end -appraise 'delayed_job-4.1-rails-6.1' do - gem 'activejob', '~> 6.1.0' + appraise 'delayed_job-latest' do + gem 'delayed_job' + gem 'activejob' + end end diff --git a/instrumentation/delayed_job/Gemfile b/instrumentation/delayed_job/Gemfile index 3c182227f..2baf57ac4 100644 --- a/instrumentation/delayed_job/Gemfile +++ b/instrumentation/delayed_job/Gemfile @@ -9,6 +9,5 @@ source 'https://rubygems.org' gemspec group :test do - gem 'delayed_job', '~> 4.1' gem 'opentelemetry-instrumentation-base', path: '../base' end diff --git a/instrumentation/rails/Appraisals b/instrumentation/rails/Appraisals index e6c48d017..2f466100e 100644 --- a/instrumentation/rails/Appraisals +++ b/instrumentation/rails/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'rails-latest' do + gem 'rails' end end diff --git a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb b/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb index 96fd40cb3..731d4fead 100644 --- a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb +++ b/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb @@ -12,7 +12,7 @@ let(:exporter) { EXPORTER } let(:spans) { exporter.finished_spans } let(:span) { exporter.finished_spans.last } - let(:rails_app) { DEFAULT_RAILS_APP } + let(:rails_app) { AppConfig.initialize_app } # Clear captured spans before { exporter.reset } diff --git a/instrumentation/rails/test/instrumentation/test_helper.rb b/instrumentation/rails/test/instrumentation/test_helper.rb index 2690c04d0..b95b64235 100644 --- a/instrumentation/rails/test/instrumentation/test_helper.rb +++ b/instrumentation/rails/test/instrumentation/test_helper.rb @@ -23,8 +23,3 @@ c.use_all c.add_span_processor span_processor end - -# Create a globally available Rails app, this should be used in test unless -# specifically testing behaviour with different initialization configs. -DEFAULT_RAILS_APP = AppConfig.initialize_app -Rails.application = DEFAULT_RAILS_APP diff --git a/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb b/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb index 3e8c23ee1..ad4898551 100644 --- a/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb +++ b/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb @@ -4,8 +4,9 @@ # # SPDX-License-Identifier: Apache-2.0 -class Application < Rails::Application; end require 'action_controller/railtie' +class Application < Rails::Application; end + require_relative 'middlewares' require_relative 'controllers' require_relative 'routes' @@ -28,7 +29,7 @@ def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: fal case Rails.version when /^6\.1/ apply_rails_6_1_configs(new_app) - when /^7\./ + when /^7|8\./ apply_rails_7_configs(new_app) end @@ -46,9 +47,7 @@ def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: fal private def remove_rack_middleware(application) - application.middleware.delete( - OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - ) + application.middleware.delete(Rack::Events) end def add_exceptions_app(application) diff --git a/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb b/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb index 9bb554655..abe86b587 100644 --- a/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb +++ b/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb @@ -12,6 +12,6 @@ def ok end def internal_server_error - raise :internal_server_error + raise 'internal_server_error' end end diff --git a/instrumentation/rails/test/instrumentation/test_helpers/routes.rb b/instrumentation/rails/test/instrumentation/test_helpers/routes.rb index 88f0565f2..bef13feb6 100644 --- a/instrumentation/rails/test/instrumentation/test_helpers/routes.rb +++ b/instrumentation/rails/test/instrumentation/test_helpers/routes.rb @@ -6,7 +6,7 @@ def draw_routes(rails_app) rails_app.routes.draw do - get '/ok', to: 'example#ok' + get 'ok', to: 'example#ok' get '/internal_server_error', to: 'example#internal_server_error' end end diff --git a/instrumentation/rails/test/railtie/dummy/tmp/.gitkeep b/instrumentation/rails/test/railtie/dummy/tmp/.gitkeep new file mode 100644 index 000000000..e69de29bb