Skip to content
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

Merged
merged 3 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,13 @@ services:
- "5432:5432"

redis:
image: redis:5.0-alpine
image: bitnami/redis:6.2
environment:
- REDIS_PASSWORD=passw0rd
volumes:
- redis_data:/data
ports:
- "16379:6379"

rabbitmq:
image: rabbitmq:3.8-alpine
Expand All @@ -179,6 +183,8 @@ services:
memcached:
image: memcached:alpine
command: memcached -m 64
ports:
- "11211:11211"

zookeeper:
image: confluentinc/cp-zookeeper:latest
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/action_pack/gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
private

def gem_version
Gem.loaded_specs['actionpack'].version
::ActionPack.version
end

def patch
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_view/gemfiles/rails_5.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_view/gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_view/gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion instrumentation/action_view/gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ 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
option :notification_payload_transform, default: nil, validate: :callable

private

def gem_version
::ActionView.version
end

def require_dependencies
require_relative 'railtie'
end
Expand Down
15 changes: 15 additions & 0 deletions instrumentation/active_job/gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -58,6 +58,10 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base

private

def gem_version
::ActiveJob.version
end

def require_dependencies
require_relative 'patches/base'
require_relative 'patches/active_job_callbacks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@

describe '#compatible' do
it 'returns false for unsupported gem versions' do
Gem.stub(:loaded_specs, 'activejob' => Gem::Specification.new { |s| s.version = '4.2.0' }) do
::ActiveJob.stub(:version, Gem::Version.new('4.2.0')) do
_(instrumentation.compatible?).must_equal false
end
end

it 'returns true for supported gem versions' do
Gem.stub(:loaded_specs, 'activejob' => Gem::Specification.new { |s| s.version = minimum_version }) do
_(instrumentation.compatible?).must_equal true
end
_(instrumentation.compatible?).must_equal true
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
private

def gem_version
Gem.loaded_specs['active_model_serializers'].version
Gem::Version.new(::ActiveModel::Serializer::VERSION)
end

def require_dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@

describe 'compatible' do
it 'when older gem version installed' do
allow_any_instance_of(Bundler::StubSpecification).to receive(:version).and_return(Gem::Version.new('0.9.4'))
stub_const('::ActiveModel::Serializer::VERSION', '0.9.4')
_(instrumentation.compatible?).must_equal false
end

it 'when future gem version installed' do
allow_any_instance_of(Bundler::StubSpecification).to receive(:version).and_return(Gem::Version.new('0.11.0'))
_(instrumentation.compatible?).must_equal true
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def insert_class_methods_supported?
end

def gem_version
Gem.loaded_specs['activerecord'].version
::ActiveRecord.version
end

def patch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,25 @@

describe 'compatible' do
it 'when a version below the minimum supported gem version is installed' do
Gem.stub(:loaded_specs, 'activerecord' => Gem::Specification.new { |s| s.version = '4.2.0' }) do
ActiveRecord.stub(:version, Gem::Version.new('4.2.0')) do
_(instrumentation.compatible?).must_equal false
end
end

it 'when a version above the maximum supported gem version is installed' do
Gem.stub(:loaded_specs, 'activerecord' => Gem::Specification.new { |s| s.version = '8.0.0' }) do
ActiveRecord.stub(:version, Gem::Version.new('8.0.0')) do
_(instrumentation.compatible?).must_equal false
end
end

it 'it treats pre releases as being equivalent to a full release' do
Gem.stub(:loaded_specs, 'activerecord' => Gem::Specification.new { |s| s.version = '8.0.0.alpha' }) do
ActiveRecord.stub(:version, Gem::Version.new('8.0.0.alpha')) do
_(instrumentation.compatible?).must_equal false
end
end

it 'when supported gem version installed' do
Gem.stub(:loaded_specs, 'activerecord' => Gem::Specification.new { |s| s.version = minimum_version }) do
_(instrumentation.compatible?).must_equal true
end
_(instrumentation.compatible?).must_equal true
end
end

Expand Down
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.10.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.11.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.8.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_2.9.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_3.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/gemfiles/aws_sdk_3.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Instrumentation
module AwsSdk
# Instrumentation class that detects and installs the AwsSdk instrumentation
class Instrumentation < OpenTelemetry::Instrumentation::Base
MINIMUM_VERSION = Gem::Version.new('2.0')
MINIMUM_VERSION = Gem::Version.new('2.0.0')

install do |_config|
require_dependencies
Expand All @@ -21,7 +21,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
end

compatible do
gem_version >= MINIMUM_VERSION
!gem_version.nil? && gem_version >= MINIMUM_VERSION
end

option :inject_messaging_context, default: false, validate: :boolean
Expand All @@ -32,6 +32,8 @@ def gem_version
Gem.loaded_specs['aws-sdk'].version
elsif Gem.loaded_specs['aws-sdk-core']
Gem.loaded_specs['aws-sdk-core'].version
elsif defined?(::Aws::CORE_GEM_VERSION)
Gem::Version.new(::Aws::CORE_GEM_VERSION)
end
end

Expand Down
Loading