From 1e564ee1ae5b4b786c95d64002ea414d91e8adc6 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Tue, 19 Nov 2024 08:11:54 -0600 Subject: [PATCH 1/2] test: Fix Sinatra Tests Sinatra 4.1 now includes a stricter host authorization check by default, which caused our tests to fail. The host authorization is not enforced in development and test mode so this PR sets the Sinatra environment to run in `test` mode. See: https://github.com/sinatra/sinatra/pull/2053 fixes https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/1252 --- .../test/opentelemetry/instrumentation/sinatra_test.rb | 5 ++++- instrumentation/sinatra/test/test_helper.rb | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb b/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb index 0425595b8..4c9d5814a 100644 --- a/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb +++ b/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb @@ -17,6 +17,7 @@ class CustomError < StandardError; end let(:app_one) do Class.new(Sinatra::Application) do + set :raise_errors, false get '/endpoint' do '1' end @@ -41,6 +42,7 @@ class CustomError < StandardError; end let(:app_two) do Class.new(Sinatra::Application) do + set :raise_errors, false get '/endpoint' do '2' end @@ -165,7 +167,8 @@ class CustomError < StandardError; end 'http.method' => 'GET', 'http.route' => '/error', 'http.scheme' => 'http', - 'http.target' => '/error' + 'http.target' => '/error', + 'http.status_code' => 500 ) _(exporter.finished_spans.flat_map(&:events).map(&:name)).must_equal(['exception']) end diff --git a/instrumentation/sinatra/test/test_helper.rb b/instrumentation/sinatra/test/test_helper.rb index 6caf4af52..48ae2a681 100644 --- a/instrumentation/sinatra/test/test_helper.rb +++ b/instrumentation/sinatra/test/test_helper.rb @@ -3,6 +3,7 @@ # Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 +ENV['APP_ENV'] = 'test' require 'bundler/setup' Bundler.require(:default, :development, :test) From 6cbe0837ac429866c48d8fa68bb1e7d188353e79 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Tue, 19 Nov 2024 08:18:31 -0600 Subject: [PATCH 2/2] squash: update appraisals --- instrumentation/sinatra/Appraisals | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/instrumentation/sinatra/Appraisals b/instrumentation/sinatra/Appraisals index f04c6775b..73cb3a9d4 100644 --- a/instrumentation/sinatra/Appraisals +++ b/instrumentation/sinatra/Appraisals @@ -4,16 +4,10 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'sinatra-4.x' do - gem 'sinatra', '~> 4.0' -end - -appraise 'sinatra-3.x' do - gem 'sinatra', '~> 3.0' -end - -appraise 'sinatra-2.x' do - gem 'sinatra', '~> 2.1' +%w[4.1 3.0 2.1].each do |version| + appraise "sinatra-#{version}" do + gem 'sinatra', "~> #{version}" + end end appraise 'sinatra-latest' do