From d6166a005dd2405dfa8b965f4a69923a357abbc3 Mon Sep 17 00:00:00 2001 From: Kayla Reopelle Date: Wed, 22 Nov 2023 11:00:31 -0800 Subject: [PATCH] chore(dev-deps): Add and enable rubocop-performance --- .../templates/gemspec.tt | 1 + .rubocop.yml | 2 ++ Gemfile | 1 + ...emetry-instrumentation-action_pack.gemspec | 1 + ...emetry-instrumentation-action_view.gemspec | 1 + .../active_job/instrumentation.rb | 2 +- ...lemetry-instrumentation-active_job.gemspec | 1 + ...mentation-active_model_serializers.gemspec | 1 + ...etry-instrumentation-active_record.gemspec | 1 + .../active_support/span_subscriber.rb | 6 ++-- ...try-instrumentation-active_support.gemspec | 1 + instrumentation/all/Gemfile | 2 +- .../opentelemetry-instrumentation-all.gemspec | 1 + ...ntelemetry-instrumentation-aws_sdk.gemspec | 1 + .../lib/opentelemetry/instrumentation/base.rb | 2 +- ...opentelemetry-instrumentation-base.gemspec | 1 + ...pentelemetry-instrumentation-bunny.gemspec | 1 + .../patches/thread_pool_executor.rb | 2 +- ...ry-instrumentation-concurrent_ruby.gemspec | 1 + .../concurrent-ruby/instrumentation_test.rb | 2 +- ...pentelemetry-instrumentation-dalli.gemspec | 1 + .../delayed_job/plugins/tracer_plugin.rb | 6 ++-- ...emetry-instrumentation-delayed_job.gemspec | 1 + .../instrumentation/ethon/patches/easy.rb | 2 +- ...pentelemetry-instrumentation-ethon.gemspec | 1 + .../excon/middlewares/tracer_middleware.rb | 2 +- ...pentelemetry-instrumentation-excon.gemspec | 1 + .../faraday/middlewares/tracer_middleware.rb | 2 +- ...ntelemetry-instrumentation-faraday.gemspec | 1 + .../instrumentation/grape/event_handler.rb | 4 +-- ...pentelemetry-instrumentation-grape.gemspec | 1 + instrumentation/grape/test/test_helper.rb | 2 +- ...ntelemetry-instrumentation-graphql.gemspec | 1 + .../graphql/tracers/graphql_trace_test.rb | 2 +- ...opentelemetry-instrumentation-gruf.gemspec | 1 + .../instrumentation/http/patches/client.rb | 2 +- ...opentelemetry-instrumentation-http.gemspec | 1 + .../http/patches/client_test.rb | 2 +- .../http_client/patches/client.rb | 2 +- ...emetry-instrumentation-http_client.gemspec | 1 + .../instrumentation/httpx/plugin.rb | 4 +-- ...pentelemetry-instrumentation-httpx.gemspec | 1 + ...pentelemetry-instrumentation-koala.gemspec | 1 + ...opentelemetry-instrumentation-lmdb.gemspec | 1 + .../mongo/command_serializer.rb | 2 +- ...pentelemetry-instrumentation-mongo.gemspec | 1 + ...entelemetry-instrumentation-mysql2.gemspec | 1 + .../net/http/patches/instrumentation.rb | 10 ++++++- ...telemetry-instrumentation-net_http.gemspec | 2 ++ .../net/http/instrumentation_test.rb | 28 +++++++++++++++++++ instrumentation/net_http/test/test_helper.rb | 1 + .../opentelemetry-instrumentation-pg.gemspec | 1 + .../pg/instrumentation_test.rb | 2 +- .../que/middlewares/server_middleware.rb | 4 +-- .../opentelemetry-instrumentation-que.gemspec | 1 + ...ntelemetry-instrumentation-racecar.gemspec | 1 + .../rack/middlewares/tracer_middleware.rb | 2 +- ...opentelemetry-instrumentation-rack.gemspec | 1 + .../rack/instrumentation_test.rb | 2 +- .../rack/middlewares/event_handler_test.rb | 2 +- .../middlewares/tracer_middleware_test.rb | 4 +-- ...pentelemetry-instrumentation-rails.gemspec | 1 + .../instrumentation/rails/railtie_test.rb | 8 +++--- ...opentelemetry-instrumentation-rake.gemspec | 1 + ...ntelemetry-instrumentation-rdkafka.gemspec | 1 + ...pentelemetry-instrumentation-redis.gemspec | 1 + ...entelemetry-instrumentation-resque.gemspec | 1 + .../restclient/patches/request.rb | 4 +-- ...lemetry-instrumentation-restclient.gemspec | 1 + .../instrumentation/rspec/formatter.rb | 2 +- ...pentelemetry-instrumentation-rspec.gemspec | 1 + ...lemetry-instrumentation-ruby_kafka.gemspec | 1 + ...ntelemetry-instrumentation-sidekiq.gemspec | 1 + ...ntelemetry-instrumentation-sinatra.gemspec | 1 + ...ntelemetry-instrumentation-trilogy.gemspec | 1 + .../propagator/ottrace/text_map_propagator.rb | 4 +-- .../opentelemetry-propagator-ottrace.gemspec | 1 + .../propagator/xray/text_map_propagator.rb | 2 +- .../opentelemetry-propagator-xray.gemspec | 1 + ...ntelemetry-resource-detector-azure.gemspec | 1 + ...emetry-resource-detector-container.gemspec | 1 + ...rce-detector-google_cloud_platform.gemspec | 1 + 82 files changed, 132 insertions(+), 43 deletions(-) diff --git a/.instrumentation_generator/templates/gemspec.tt b/.instrumentation_generator/templates/gemspec.tt index 6305d176e..cadf4adc7 100644 --- a/.instrumentation_generator/templates/gemspec.tt +++ b/.instrumentation_generator/templates/gemspec.tt @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.48.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.7.6' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/.rubocop.yml b/.rubocop.yml index efc914429..028015df7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +require: rubocop-performance + AllCops: TargetRubyVersion: '3.0' NewCops: enable diff --git a/Gemfile b/Gemfile index 79b6ff11e..303d87c32 100644 --- a/Gemfile +++ b/Gemfile @@ -8,3 +8,4 @@ source 'https://rubygems.org' gem 'rake', '~> 13.0' gem 'rubocop', '~> 1.57.1' +gem 'rubocop-performance', '~> 1.19.1' diff --git a/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec b/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec index 2e23f7fef..63f11e851 100644 --- a/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec +++ b/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec b/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec index fe22f24db..1c9a269af 100644 --- a/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec +++ b/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' 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 e475247f8..d9c6063c5 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/instrumentation.rb @@ -68,7 +68,7 @@ def require_dependencies end def patch_activejob - ::ActiveJob::Base.prepend(Patches::Base) unless ::ActiveJob::Base.ancestors.include?(Patches::Base) + ::ActiveJob::Base.prepend(Patches::Base) unless ::ActiveJob::Base <= Patches::Base Handlers.subscribe end diff --git a/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec b/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec index 8488ed675..368343f4b 100644 --- a/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec +++ b/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec b/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec index fa465c7ac..d3265fbdc 100644 --- a/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec +++ b/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec index dcfa69779..ec0ac630a 100644 --- a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec +++ b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb index e2ab1d700..71692168a 100644 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb +++ b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb @@ -67,10 +67,8 @@ def start(name, id, payload) token = OpenTelemetry::Context.attach( OpenTelemetry::Trace.context_with_span(span) ) - payload.merge!( - __opentelemetry_span: span, - __opentelemetry_ctx_token: token - ) + payload[:__opentelemetry_span] = span + payload[:__opentelemetry_ctx_token] = token [span, token] end diff --git a/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec b/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec index f9fdb4027..c88e74003 100644 --- a/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec +++ b/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec @@ -39,6 +39,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/all/Gemfile b/instrumentation/all/Gemfile index 4ef786f4f..5cfaa5c0b 100644 --- a/instrumentation/all/Gemfile +++ b/instrumentation/all/Gemfile @@ -11,7 +11,7 @@ gemspec group :test do Dir.entries('../') .select { |entry| File.directory?(File.join('../', entry)) } - .reject { |entry| %w[. .. all].include?(entry) } + .reject { |entry| %w[. .. all].include?(entry) } # rubocop:disable Performance/CollectionLiteralInLoop .sort .each { |dir| gem "opentelemetry-instrumentation-#{dir}", path: "../#{dir}" } end diff --git a/instrumentation/all/opentelemetry-instrumentation-all.gemspec b/instrumentation/all/opentelemetry-instrumentation-all.gemspec index 29bda9d02..61d225be8 100644 --- a/instrumentation/all/opentelemetry-instrumentation-all.gemspec +++ b/instrumentation/all/opentelemetry-instrumentation-all.gemspec @@ -66,6 +66,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec b/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec index 1c91da124..47c008962 100644 --- a/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec +++ b/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec @@ -38,6 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb b/instrumentation/base/lib/opentelemetry/instrumentation/base.rb index d944d1a6c..4e08be3ea 100644 --- a/instrumentation/base/lib/opentelemetry/instrumentation/base.rb +++ b/instrumentation/base/lib/opentelemetry/instrumentation/base.rb @@ -353,7 +353,7 @@ def coerce_env_var(env_var, validation_type) when :array env_var.split(',').map(&:strip) when :boolean - env_var.to_s.strip.downcase == 'true' + env_var.to_s.strip.casecmp('true').zero? when :integer env_var.to_i when :string diff --git a/instrumentation/base/opentelemetry-instrumentation-base.gemspec b/instrumentation/base/opentelemetry-instrumentation-base.gemspec index 98ab793c7..e699d4e72 100644 --- a/instrumentation/base/opentelemetry-instrumentation-base.gemspec +++ b/instrumentation/base/opentelemetry-instrumentation-base.gemspec @@ -33,6 +33,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.57.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec b/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec index 40aa3a9f5..286692bcd 100644 --- a/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec +++ b/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb b/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb index 5b7f1e5e7..db8873ea2 100644 --- a/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb +++ b/instrumentation/concurrent_ruby/lib/opentelemetry/instrumentation/concurrent_ruby/patches/thread_pool_executor.rb @@ -17,7 +17,7 @@ def post(*args, **kwargs, &task) super(*args, **kwargs) do OpenTelemetry::Context.with_current(context) do - task.call(*args, **kwargs) + yield(*args, **kwargs) end end end diff --git a/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec b/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec index 9b99f1e2a..3956fb3d6 100644 --- a/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec +++ b/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb b/instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb index c3f538443..2aa4e5ceb 100644 --- a/instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb +++ b/instrumentation/concurrent_ruby/test/opentelemetry/instrumentation/concurrent-ruby/instrumentation_test.rb @@ -23,7 +23,7 @@ after do # Force re-install of instrumentation Concurrent.send(:remove_const, :ThreadPoolExecutor) - Concurrent.const_set('ThreadPoolExecutor', unmodified_future) + Concurrent.const_set(:ThreadPoolExecutor, unmodified_future) instrumentation.instance_variable_set(:@installed, false) end diff --git a/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec b/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec index 8a12e2360..173cbbca5 100644 --- a/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec +++ b/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb index 304868adb..676f720ed 100644 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb +++ b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb @@ -14,7 +14,7 @@ module Plugins class TracerPlugin < Delayed::Plugin class << self def instrument_enqueue(job, &block) - return block.call(job) unless enabled? + return yield(job) unless enabled? attributes = build_attributes(job) attributes['messaging.operation'] = 'publish' @@ -28,7 +28,7 @@ def instrument_enqueue(job, &block) end def instrument_invoke(job, &block) - return block.call(job) unless enabled? + return yield(job) unless enabled? attributes = build_attributes(job) attributes['messaging.delayed_job.attempts'] = job.attempts if job.attempts @@ -83,8 +83,10 @@ def job_queue(job) end callbacks do |lifecycle| + # rubocop:disable Performance/MethodObjectAsBlock lifecycle.around(:enqueue, &method(:instrument_enqueue)) lifecycle.around(:invoke_job, &method(:instrument_invoke)) + # rubocop:enable Performance/MethodObjectAsBlock end end end diff --git a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec index 9978617c2..3d57df13d 100644 --- a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec +++ b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'sqlite3' spec.add_development_dependency 'webmock', '~> 3.19' diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb index f8727126d..18b11dc51 100644 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb +++ b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb @@ -42,7 +42,7 @@ def complete @otel_span.status = OpenTelemetry::Trace::Status.error("Request has failed: #{message}") else @otel_span.set_attribute('http.status_code', response_code) - @otel_span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response_code.to_i) + @otel_span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response_code.to_i) end ensure @otel_span&.finish diff --git a/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec b/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec index ee41e5925..e9880c1b2 100644 --- a/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec +++ b/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb index 264bf5067..856a52114 100644 --- a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb +++ b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb @@ -78,7 +78,7 @@ def handle_response(datum) if datum.key?(:response) response = datum[:response] span.set_attribute('http.status_code', response[:status]) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response[:status].to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response[:status].to_i) end span.status = OpenTelemetry::Trace::Status.error("Request has failed: #{datum[:error]}") if datum.key?(:error) diff --git a/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec b/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec index 117c4e6f1..d74e9e265 100644 --- a/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec +++ b/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb index c6b73c3c9..01c6da394 100644 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb +++ b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb @@ -60,7 +60,7 @@ def tracer def trace_response(span, response) span.set_attribute('http.status_code', response.status) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response.status.to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response.status.to_i) end end end diff --git a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec b/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec index ac9527d5e..32de7c6b2 100644 --- a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec +++ b/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb b/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb index 7228247fc..2efe401fd 100644 --- a/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb +++ b/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb @@ -79,7 +79,7 @@ def handle_payload_exception(span, exception) # Only record exceptions if they were not raised (i.e. do not have a status code in Grape) # or do not have a 5xx status code. These exceptions are recorded by Rack. # See instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb#L155 - return unless exception.respond_to?('status') && ::Rack::Utils.status_code(exception.status) < 500 + return unless exception.respond_to?(:status) && ::Rack::Utils.status_code(exception.status) < 500 span.record_exception(exception) span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{exception.class}") @@ -108,7 +108,7 @@ def formatter_type(formatter) end def built_in_grape_formatter?(formatter) - formatter.respond_to?('name') && formatter.name.include?('Grape::Formatter') + formatter.respond_to?(:name) && formatter.name.include?('Grape::Formatter') end end end diff --git a/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec b/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec index 1d59fb9a6..b6191c61a 100644 --- a/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec +++ b/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec @@ -40,6 +40,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/grape/test/test_helper.rb b/instrumentation/grape/test/test_helper.rb index b079d1571..7b12c181c 100644 --- a/instrumentation/grape/test/test_helper.rb +++ b/instrumentation/grape/test/test_helper.rb @@ -23,7 +23,7 @@ # Helper functions def uninstall_and_cleanup - instrumentation.instance_variable_set('@installed', false) + instrumentation.instance_variable_set(:@installed, false) unsubscribe EXPORTER.reset end diff --git a/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec b/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec index c5a8678c3..ea8841898 100644 --- a/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec +++ b/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb index 5d4111b74..59de00473 100644 --- a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb +++ b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb @@ -291,7 +291,7 @@ describe 'compatibility with other tracers' do let(:config) { { enable_platform_field: true } } - if GraphQL::Tracing.const_defined?('PlatformTrace') + if GraphQL::Tracing.const_defined?(:PlatformTrace) module CustomPlatformTracer include ::GraphQL::Tracing::PlatformTrace diff --git a/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec b/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec index 4a7a0b550..ccf238b9f 100644 --- a/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec +++ b/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers' spec.add_development_dependency 'rake', '~> 12.3.3' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb index 21153a926..f814e1a65 100644 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb +++ b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb @@ -43,7 +43,7 @@ def annotate_span_with_response!(span, response) status_code = response.status.to_i span.set_attribute('http.status_code', status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status_code.to_i) end def create_request_span_name(request_method, request_path) diff --git a/instrumentation/http/opentelemetry-instrumentation-http.gemspec b/instrumentation/http/opentelemetry-instrumentation-http.gemspec index c8cd137b4..3ae752a76 100644 --- a/instrumentation/http/opentelemetry-instrumentation-http.gemspec +++ b/instrumentation/http/opentelemetry-instrumentation-http.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/http/test/instrumentation/http/patches/client_test.rb b/instrumentation/http/test/instrumentation/http/patches/client_test.rb index 65ba6569c..30a8df2d7 100644 --- a/instrumentation/http/test/instrumentation/http/patches/client_test.rb +++ b/instrumentation/http/test/instrumentation/http/patches/client_test.rb @@ -26,7 +26,7 @@ propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator OpenTelemetry.propagation = propagator # simulate a fresh install: - instrumentation.instance_variable_set('@installed', false) + instrumentation.instance_variable_set(:@installed, false) instrumentation.install(config) stub_request(:get, 'http://example.com/success').to_return(status: 200) stub_request(:post, 'http://example.com/failure').to_return(status: 500) diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb index fcdae5e70..a71c8ad7b 100644 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb +++ b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb @@ -42,7 +42,7 @@ def annotate_span_with_response!(span, response) status_code = response.status_code.to_i span.set_attribute('http.status_code', status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status_code.to_i) end def tracer diff --git a/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec b/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec index 6bd4328fe..be1d42f39 100644 --- a/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec +++ b/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb b/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb index 10738e1ed..137fca976 100644 --- a/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb +++ b/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb @@ -16,7 +16,7 @@ def initialize(request) end def call - @request.on(:response, &method(:finish)) + @request.on(:response, &method(:finish)) # rubocop:disable Performance/MethodObjectAsBlock uri = @request.uri request_method = @request.verb @@ -54,7 +54,7 @@ def finish(response) @span.status = Trace::Status.error("Unhandled exception of type: #{response.error.class}") else @span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response.status) - @span.status = Trace::Status.error unless (100..399).include?(response.status) + @span.status = Trace::Status.error unless (100..399).cover?(response.status) end OpenTelemetry::Context.detach(@trace_token) if @trace_token diff --git a/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec b/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec index 6531619a7..6a80d4f37 100644 --- a/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec +++ b/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec b/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec index 578fd1e1c..2bae9dc8f 100644 --- a/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec +++ b/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec @@ -38,6 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec b/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec index f5c24419d..9f9c70cd1 100644 --- a/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec +++ b/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb index 3d3c217e6..3696c102f 100644 --- a/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb +++ b/instrumentation/mongo/lib/opentelemetry/instrumentation/mongo/command_serializer.rb @@ -75,7 +75,7 @@ def build_pipeline pipeline = command['pipeline'] return unless pipeline - payload['pipeline'] = pipeline.map(&method(:mask)) + payload['pipeline'] = pipeline.map { |x| mask(x) } end def add_val(payload, command, key) diff --git a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec b/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec index 38fa563e1..d7c66371e 100644 --- a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec +++ b/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec @@ -38,6 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec b/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec index e4cdc1c55..0ca7f66c9 100644 --- a/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec +++ b/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb index 32a67122c..2edcc2274 100644 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb +++ b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb @@ -78,7 +78,7 @@ def annotate_span_with_response!(span, response) status_code = response.code.to_i span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(status_code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status_code.to_i) end def tracer @@ -86,12 +86,20 @@ def tracer end def untraced? + untraced_context? || untraced_host? + end + + def untraced_host? return true if Net::HTTP::Instrumentation.instance.config[:untraced_hosts]&.any? do |host| host.is_a?(Regexp) ? host.match?(@address) : host == @address end false end + + def untraced_context? + OpenTelemetry::Common::Utilities.untraced? + end end end end diff --git a/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec b/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec index d61af1b88..eeae361cb 100644 --- a/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec +++ b/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec @@ -34,7 +34,9 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0.1' + spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb b/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb index 2ab764299..fb4d61a92 100644 --- a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb +++ b/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb @@ -178,6 +178,34 @@ _(span.attributes['net.peer.port']).must_equal(80) end end + + describe 'untraced context' do + it 'no-ops on #request' do + # Calling `tracer.in_span` within an untraced context causes the logging of "called + # finish on an ended Span" messages. To avoid log noise, the instrumentation must + # no-op (i.e., not call `tracer.in_span`) when the context is untraced. + expect(instrumentation.tracer).not_to receive(:in_span) + + OpenTelemetry::Common::Utilities.untraced do + Net::HTTP.get('example.com', '/body') + end + + _(exporter.finished_spans.size).must_equal 0 + end + + it 'no-ops on #connect' do + expect(instrumentation.tracer).not_to receive(:in_span) + + OpenTelemetry::Common::Utilities.untraced do + uri = URI.parse('http://example.com/body') + http = Net::HTTP.new(uri.host, uri.port) + http.send(:connect) + http.send(:do_finish) + end + + _(exporter.finished_spans.size).must_equal 0 + end + end end describe '#connect' do diff --git a/instrumentation/net_http/test/test_helper.rb b/instrumentation/net_http/test/test_helper.rb index d617b91c2..921a7e11c 100644 --- a/instrumentation/net_http/test/test_helper.rb +++ b/instrumentation/net_http/test/test_helper.rb @@ -9,6 +9,7 @@ Bundler.require(:default, :development, :test) require 'minitest/autorun' +require 'rspec/mocks/minitest_integration' require 'webmock/minitest' # global opentelemetry-sdk setup: diff --git a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec b/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec index 2c77b6629..305865c37 100644 --- a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec +++ b/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec @@ -38,6 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb b/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb index 32dedf646..332e90720 100644 --- a/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb +++ b/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb @@ -346,7 +346,7 @@ client.query('SELECT 1') _(span.attributes['net.peer.name']).must_equal host - _(span.attributes['net.peer.port']).must_equal port.to_i if PG.const_defined?('DEF_PORT') + _(span.attributes['net.peer.port']).must_equal port.to_i if PG.const_defined?(:DEF_PORT) end end end unless ENV['OMIT_SERVICES'] diff --git a/instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb b/instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb index 1e5c0c15d..386a6d5cd 100644 --- a/instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb +++ b/instrumentation/que/lib/opentelemetry/instrumentation/que/middlewares/server_middleware.rb @@ -20,7 +20,7 @@ def self.call(job, &block) OpenTelemetry::Context.with_current(extracted_context) do if otel_config[:propagation_style] == :child tracer.in_span(span_name, attributes: attributes, kind: :consumer) do |span| - block.call + yield enhance_span_after_job_completion(span, job) end else @@ -28,7 +28,7 @@ def self.call(job, &block) root_span = tracer.start_root_span(span_name, attributes: attributes, links: span_links, kind: :consumer) OpenTelemetry::Trace.with_span(root_span) do |span| - block.call + yield enhance_span_after_job_completion(span, job) ensure root_span.finish diff --git a/instrumentation/que/opentelemetry-instrumentation-que.gemspec b/instrumentation/que/opentelemetry-instrumentation-que.gemspec index 603b863f0..8708ff4e4 100644 --- a/instrumentation/que/opentelemetry-instrumentation-que.gemspec +++ b/instrumentation/que/opentelemetry-instrumentation-que.gemspec @@ -39,6 +39,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'que' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec b/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec index cb52a1d09..56e0e4ca6 100644 --- a/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec +++ b/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec @@ -38,6 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb index d68c7400a..353d5192f 100644 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb +++ b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb @@ -150,7 +150,7 @@ def create_request_span_name(request_uri_or_path_info, env) end def set_attributes_after_request(span, status, headers, _response) - span.status = OpenTelemetry::Trace::Status.error unless (100..499).include?(status.to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..499).cover?(status.to_i) span.set_attribute('http.status_code', status) # NOTE: if data is available, it would be good to do this: diff --git a/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec b/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec index 35d20b559..b6c38b594 100644 --- a/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec +++ b/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec @@ -40,6 +40,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb index 2814bde0d..3e9529245 100644 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb +++ b/instrumentation/rack/test/opentelemetry/instrumentation/rack/instrumentation_test.rb @@ -13,7 +13,7 @@ before do # simulate a fresh install: - instrumentation.instance_variable_set('@installed', false) + instrumentation.instance_variable_set(:@installed, false) instrumentation.config.clear end diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/event_handler_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/event_handler_test.rb index ff43da7d1..d08857637 100644 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/event_handler_test.rb +++ b/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/event_handler_test.rb @@ -63,7 +63,7 @@ exporter.reset # simulate a fresh install: - instrumentation.instance_variable_set('@installed', false) + instrumentation.instance_variable_set(:@installed, false) instrumentation.install(config) end diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb index 5e9df36e8..9deb47183 100644 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb +++ b/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb @@ -36,7 +36,7 @@ exporter.reset # simulate a fresh install: - instrumentation.instance_variable_set('@installed', false) + instrumentation.instance_variable_set(:@installed, false) instrumentation.install(config) # clear out cached config: @@ -49,7 +49,7 @@ after do # installation is 'global', so it should be reset: - instrumentation.instance_variable_set('@installed', false) + instrumentation.instance_variable_set(:@installed, false) instrumentation.install(default_config) end diff --git a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec b/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec index a5660cec1..83311c377 100644 --- a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec +++ b/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec @@ -42,6 +42,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb b/instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb index b3465aaf8..53911790d 100644 --- a/instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb +++ b/instrumentation/rails/test/railtie/opentelemetry/instrumentation/rails/railtie_test.rb @@ -9,10 +9,10 @@ class OpenTelemetry::Instrumentation::Rails::RailtieTest < ActiveSupport::TestCa include OpenTelemetry::SemanticConventions setup do - OpenTelemetry::Instrumentation.registry.instance_variable_get('@instrumentation').each do |i| - i.instance_variable_set('@instance', nil) + OpenTelemetry::Instrumentation.registry.instance_variable_get(:@instrumentation).each do |i| + i.instance_variable_set(:@instance, nil) end - OpenTelemetry::SDK::Resources::Resource.instance_variable_set('@default', nil) + OpenTelemetry::SDK::Resources::Resource.instance_variable_set(:@default, nil) OpenTelemetry.tracer_provider = OpenTelemetry::Internal::ProxyTracerProvider.new end @@ -20,7 +20,7 @@ class OpenTelemetry::Instrumentation::Rails::RailtieTest < ActiveSupport::TestCa OpenTelemetry::TestHelpers.with_env('OTEL_SERVICE_NAME' => nil) do run_initializer assert_instance_of(OpenTelemetry::SDK::Trace::TracerProvider, OpenTelemetry.tracer_provider) - assert_same(Rails.logger, OpenTelemetry.logger.instance_variable_get('@logger')) + assert_same(Rails.logger, OpenTelemetry.logger.instance_variable_get(:@logger)) end end diff --git a/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec b/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec index 086244590..a7b28ef1e 100644 --- a/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec +++ b/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '>= 0.9.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec b/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec index 9dbd122db..ce13e3e3b 100644 --- a/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec +++ b/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec @@ -38,6 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rdkafka', '>= 0.12' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec b/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec index 2d319abec..4985c9f29 100644 --- a/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec +++ b/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'redis', '~> 4.1' spec.add_development_dependency 'redis-client', '~> 0.7' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec b/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec index 6294c5453..44b51fe8f 100644 --- a/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec +++ b/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'resque' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb index dd98bf912..7ba48061b 100644 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb +++ b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb @@ -49,12 +49,12 @@ def trace_request # If so, add additional attributes. if response.is_a?(::RestClient::Response) span.set_attribute('http.status_code', response.code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response.code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response.code.to_i) end end rescue ::RestClient::ExceptionWithResponse => e span.set_attribute('http.status_code', e.http_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(e.http_code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(e.http_code.to_i) raise e ensure diff --git a/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec b/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec index f3ab560f8..39c7a7670 100644 --- a/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec +++ b/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rest-client', '~> 2.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb index 538625c23..11a37b8f8 100644 --- a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb +++ b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb @@ -121,7 +121,7 @@ def strip_console_codes(string) end def multiple_failure_message(exception) - exception.failures.map(&:message).map(&method(:strip_console_codes)).join("\n\n") + exception.failures.map(&:message).map { |x| strip_console_codes(x) }.join("\n\n") end end end diff --git a/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec b/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec index 976bd7c10..10813eb9a 100644 --- a/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec +++ b/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec', '~> 3.10.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.19' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec b/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec index 740399830..ed4a1638f 100644 --- a/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec +++ b/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'ruby-kafka' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec index 40c5dce8e..163fe3413 100644 --- a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec +++ b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'sidekiq' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec b/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec index 8073e3a7c..dfefd8a6d 100644 --- a/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec +++ b/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rack-test', '~> 1.1.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'sinatra' spec.add_development_dependency 'webmock', '~> 3.19' diff --git a/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec b/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec index d3cad653a..fad870ebe 100644 --- a/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec +++ b/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec @@ -39,6 +39,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'trilogy', '>= 2.0', '< 3.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb index bbbfd19e0..40604fba0 100644 --- a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb +++ b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb @@ -116,10 +116,10 @@ def set_baggage(carrier:, context:, getter:) getter.keys(carrier).each do |carrier_key| baggage_key = carrier_key.start_with?(prefix) && carrier_key[prefix.length..-1] next unless baggage_key - next unless VALID_BAGGAGE_HEADER_NAME_CHARS =~ baggage_key + next unless VALID_BAGGAGE_HEADER_NAME_CHARS.match?(baggage_key) value = getter.get(carrier, carrier_key) - next unless INVALID_BAGGAGE_HEADER_VALUE_CHARS !~ value + next if INVALID_BAGGAGE_HEADER_VALUE_CHARS.match?(value) builder.set_value(baggage_key, value) end diff --git a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec index cacacdd6c..370b050f8 100644 --- a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec +++ b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec @@ -29,6 +29,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.57.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb b/propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb index ee1f8ce05..1041643ac 100644 --- a/propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb +++ b/propagator/xray/lib/opentelemetry/propagator/xray/text_map_propagator.rb @@ -119,7 +119,7 @@ def to_trace_flags(sampling_state) def to_trace_state(trace_state) return nil unless trace_state - Trace::Tracestate.from_string(trace_state.gsub(';', ',')) + Trace::Tracestate.from_string(trace_state.tr(';', ',')) end end end diff --git a/propagator/xray/opentelemetry-propagator-xray.gemspec b/propagator/xray/opentelemetry-propagator-xray.gemspec index 66da780a5..5a44a8a71 100644 --- a/propagator/xray/opentelemetry-propagator-xray.gemspec +++ b/propagator/xray/opentelemetry-propagator-xray.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.57.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/resources/azure/opentelemetry-resource-detector-azure.gemspec b/resources/azure/opentelemetry-resource-detector-azure.gemspec index 0c3d09755..4b077e0be 100644 --- a/resources/azure/opentelemetry-resource-detector-azure.gemspec +++ b/resources/azure/opentelemetry-resource-detector-azure.gemspec @@ -31,6 +31,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.55.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17' spec.add_development_dependency 'webmock', '~> 3.19.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/resources/container/opentelemetry-resource-detector-container.gemspec b/resources/container/opentelemetry-resource-detector-container.gemspec index baf1db746..a596d3014 100644 --- a/resources/container/opentelemetry-resource-detector-container.gemspec +++ b/resources/container/opentelemetry-resource-detector-container.gemspec @@ -31,6 +31,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec b/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec index 931751f63..464fb1ae5 100644 --- a/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec +++ b/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.55.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17' spec.add_development_dependency 'webmock', '~> 3.19.1' spec.add_development_dependency 'yard', '~> 0.9'