scout_apm 5.3.1 → 5.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3d15e4a9b9e98af3e71ba6dde0b666b8807b742f967e35fe36ebd747ae83483
4
- data.tar.gz: f8e88492777b44cdc9362500b7ccdcb68daaa756d6c98ec2e114e231e240071d
3
+ metadata.gz: 656e36a7b9a11b5870058c46b31e8227c628691f8ab7f7d4de991c3e89b5f13d
4
+ data.tar.gz: 5f27c0af5b3f864a96ea65944c6655106a86aa96dbf489083b1c3a178322d827
5
5
  SHA512:
6
- metadata.gz: bb7224bc3294417f72279a97713b9be39bd9657efa1b9c39fb969164f353cdd04c8ced4114e6b717d7ed315c86b5412d8591132f3adde543fb09f8ea908e0308
7
- data.tar.gz: 354cd7af52c07bb78380614d7aafdde9942a1b3ea973ad0616df187a2f2048b3a04fee9cff737d836c14caef142fec31aafef22e5ee4dfeb2125d31c6ea39f70
6
+ metadata.gz: b805ac798aa0f430182e31e9d4b3d924d20624a59406d333f8d8d02ead0d30bece36bf0b127b4b9e04a5cf149cc9e67621ab72f2143f7fcd5c03f70790fedf09
7
+ data.tar.gz: 6883c955de7003baeb2685c369f63532b45e1c25b5859067fdfb2112e31abae6f57e2dc44dd5b06f55d66f3a6b9b778904de864c45905a63cdd9516719d59367
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
 
9
9
  steps:
10
- - uses: actions/checkout@v2
10
+ - uses: actions/checkout@v3
11
11
  - uses: ruby/setup-ruby@v1
12
12
  with:
13
13
  bundler-cache: true
@@ -37,29 +37,31 @@ jobs:
37
37
  - ruby: 2.7
38
38
  - ruby: 2.7
39
39
  prepend: true
40
- - ruby: 3.0
41
- - ruby: 3.0
40
+ - ruby: "3.0"
41
+ - ruby: "3.0"
42
42
  prepend: true
43
- - ruby: 3.0
43
+ - ruby: "3.0"
44
44
  gemfile: gems/instruments.gemfile
45
45
  test_features: "instruments"
46
- - ruby: 3.0
46
+ - ruby: "3.0"
47
47
  gemfile: gems/instruments.gemfile
48
48
  prepend: true
49
49
  test_features: "instruments"
50
- - ruby: 3.0
50
+ - ruby: "3.0"
51
51
  gemfile: gems/sidekiq.gemfile
52
52
  test_features: "sidekiq_install"
53
-
53
+ - ruby: 3.1
54
+ - ruby: 3.2
54
55
  env:
55
56
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
56
57
  SCOUT_TEST_FEATURES: ${{ matrix.test_features }}
57
58
  SCOUT_USE_PREPEND: ${{ matrix.prepend }}
58
59
 
59
- runs-on: ubuntu-latest
60
+ # https://github.com/ruby/setup-ruby/issues/496
61
+ runs-on: ${{ matrix.ruby == '2.2' && 'ubuntu-20.04' || 'ubuntu-latest' }}
60
62
 
61
63
  steps:
62
- - uses: actions/checkout@v2
64
+ - uses: actions/checkout@v3
63
65
  - uses: ruby/setup-ruby@v1
64
66
  with:
65
67
  bundler-cache: true
data/CHANGELOG.markdown CHANGED
@@ -1,8 +1,25 @@
1
1
  # Unreleased
2
2
 
3
+ # 5.3.5
4
+ * Fix adding instrumentation of ActiveRecord after configuration has initialized for Rails versions greater than 3. (#465)
5
+ * Fix typo with double use of PercentilePolicy, instead of PercentPolicy, for scoring. (#468)
6
+ * Fix span annotations/desc for external service requests with the use of prepend. (#471)
7
+ * Fix ActiveSupport methods and replace them with non ActiveSupport methods. (#474)
8
+
9
+ # 5.3.4
10
+ Unused.
11
+
12
+ # 5.3.3
13
+
14
+ * Fix double firing of Puma `on_worker_boot` when preloading. (#463)
15
+
16
+ # 5.3.2
17
+
18
+ * Update redis instruments to support redis v5.0+ (#458)
3
19
  # 5.3.1
4
20
 
5
21
  * Fix typo in HTTPClient prepend instrumentation (#457)
22
+
6
23
  # 5.3.0
7
24
 
8
25
  * Add configuraiton option to use `Module#prepend` instead of `Module#alias_method` (default)
data/gems/sidekiq.gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  eval_gemfile("../Gemfile")
2
2
 
3
3
  # https://github.com/scoutapp/scout_apm_ruby/issues/449
4
- gem 'sidekiq', '>= 6.5.0'
4
+ gem 'sidekiq', '~> 6.5.0'
@@ -35,6 +35,7 @@ module ScoutApm
35
35
  install_instrument(ScoutApm::Instruments::HTTP)
36
36
  install_instrument(ScoutApm::Instruments::Memcached)
37
37
  install_instrument(ScoutApm::Instruments::Redis)
38
+ install_instrument(ScoutApm::Instruments::Redis5)
38
39
  install_instrument(ScoutApm::Instruments::InfluxDB)
39
40
  install_instrument(ScoutApm::Instruments::Elasticsearch)
40
41
  install_instrument(ScoutApm::Instruments::Grape)
@@ -66,7 +66,7 @@ module ScoutApm
66
66
  defined?(::Rails) &&
67
67
  defined?(::Rails::VERSION) &&
68
68
  defined?(::Rails::VERSION::MAJOR) &&
69
- ::Rails::VERSION::MAJOR.to_i == 3 &&
69
+ ::Rails::VERSION::MAJOR.to_i >= 3 &&
70
70
  ::Rails.respond_to?(:configuration)
71
71
  end
72
72
 
@@ -60,7 +60,7 @@ module ScoutApm
60
60
 
61
61
  module NetHttpInstrumentationPrepend
62
62
  def request(request, *args, &block)
63
- self.class.instrument("HTTP", "request", :ignore_children => true, :desc => request_scout_description(args.first)) do
63
+ self.class.instrument("HTTP", "request", :ignore_children => true, :desc => request_scout_description(request)) do
64
64
  super(request, *args, &block)
65
65
  end
66
66
  end
@@ -17,7 +17,7 @@ module ScoutApm
17
17
  end
18
18
 
19
19
  def install(prepend:)
20
- if defined?(::Redis) && defined?(::Redis::Client)
20
+ if defined?(::Redis) && defined?(::Redis::Client) && ::Redis::Client.instance_methods(false).include?(:call)
21
21
  @installed = true
22
22
 
23
23
  logger.info "Instrumenting Redis. Prepend: #{prepend}"
@@ -0,0 +1,59 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ class Redis5
4
+ attr_reader :context
5
+
6
+ def initialize(context)
7
+ @context = context
8
+ @installed = false
9
+ end
10
+
11
+ def logger
12
+ context.logger
13
+ end
14
+
15
+ def installed?
16
+ @installed
17
+ end
18
+
19
+ def install(prepend:)
20
+ if defined?(::Redis) && defined?(::Redis::Client) && ::Redis::Client.instance_methods(false).include?(:call_v)
21
+ @installed = true
22
+
23
+ logger.info "Instrumenting Redis5. Prepend: #{prepend}"
24
+
25
+ if prepend
26
+ ::Redis::Client.send(:include, ScoutApm::Tracer)
27
+ ::Redis::Client.send(:prepend, Redis5ClientInstrumentationPrepend)
28
+ else
29
+ ::Redis::Client.class_eval do
30
+ include ScoutApm::Tracer
31
+
32
+ def call_with_scout_instruments(args, &block)
33
+ command = args.first rescue "Unknown"
34
+
35
+ self.class.instrument("Redis", command) do
36
+ call_without_scout_instruments(args, &block)
37
+ end
38
+ end
39
+
40
+ alias_method :call_without_scout_instruments, :call_v
41
+ alias_method :call_v, :call_with_scout_instruments
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ module Redis5ClientInstrumentationPrepend
49
+ def call(args, &block)
50
+ command = args.first rescue "Unknown"
51
+
52
+ self.class.instrument("Redis", command) do
53
+ super(args, &block)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
@@ -53,7 +53,7 @@ module ScoutApm
53
53
  rescue
54
54
  # Do nothing
55
55
  ensure
56
- domain = DEFAULT_DOMAIN if domain.to_s.blank?
56
+ domain = DEFAULT_DOMAIN if (domain.nil? || domain.empty?)
57
57
  domain
58
58
  end
59
59
 
@@ -23,8 +23,36 @@ module ScoutApm
23
23
  defined?(::Puma) && (File.basename($0) =~ /\Apuma/)
24
24
  end
25
25
 
26
+ # Puma::UserFileDefaultOptions exposes `options` based on three underlying
27
+ # hashes: user_options, file_options, and default_options. While getting an `options`
28
+ # key consults all three underlying hashes, setting an `options` key only sets the
29
+ # user_options hash:
30
+ #
31
+ # def [](key)
32
+ # fetch(key)
33
+ # end
34
+ #
35
+ # def []=(key, value)
36
+ # user_options[key] = value
37
+ # end
38
+ #
39
+ # def fetch(key, default_value = nil)
40
+ # return user_options[key] if user_options.key?(key)
41
+ # return file_options[key] if file_options.key?(key)
42
+ # return default_options[key] if default_options.key?(key)
43
+ #
44
+ # default_value
45
+ # end
46
+ #
47
+ # Because of this, we can't read options[:before_worker_boot], modify, and then re-set
48
+ # options[:before_worker_boot], since doing so could cause duplication if `before_worker_boot`
49
+ # exists on the other two underlying hashes (file_options, default_options).
50
+ #
51
+ # To get around this, we explicitly read from `user_options` only, and still set using `options[]=`,
52
+ # which Puma allows for setting `user_options`.
53
+ #
26
54
  def install
27
- old = ::Puma.cli_config.options[:before_worker_boot] || []
55
+ old = ::Puma.cli_config.options.user_options[:before_worker_boot] || []
28
56
  new = Array(old) + [Proc.new do
29
57
  logger.info "Installing Puma worker loop."
30
58
  ScoutApm::Agent.instance.start_background_worker
@@ -14,7 +14,7 @@ module ScoutApm
14
14
 
15
15
  def add_default_policies
16
16
  add(SlowPolicy::SpeedPolicy.new(context))
17
- add(SlowPolicy::PercentilePolicy.new(context))
17
+ add(SlowPolicy::PercentPolicy.new(context))
18
18
  add(SlowPolicy::AgePolicy.new(context))
19
19
  add(SlowPolicy::PercentilePolicy.new(context))
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "5.3.1"
2
+ VERSION = "5.3.5"
3
3
  end
data/lib/scout_apm.rb CHANGED
@@ -87,6 +87,7 @@ require 'scout_apm/instruments/moped'
87
87
  require 'scout_apm/instruments/mongoid'
88
88
  require 'scout_apm/instruments/memcached'
89
89
  require 'scout_apm/instruments/redis'
90
+ require 'scout_apm/instruments/redis5'
90
91
  require 'scout_apm/instruments/influxdb'
91
92
  require 'scout_apm/instruments/elasticsearch'
92
93
  require 'scout_apm/instruments/active_record'
data/test/test_helper.rb CHANGED
@@ -65,6 +65,32 @@ class FakeEnvironment
65
65
  end
66
66
  end
67
67
 
68
+ def fake_rails(version)
69
+ Kernel.const_set("Rails", Module.new)
70
+ Kernel.const_set("ActionController", Module.new)
71
+ r = Kernel.const_get("Rails")
72
+ r.const_set("VERSION", Module.new)
73
+ v = r.const_get("VERSION")
74
+ v.const_set("MAJOR", version)
75
+
76
+ assert_equal version, Rails::VERSION::MAJOR
77
+ end
78
+
79
+ def clean_fake_rails
80
+ Kernel.send(:remove_const, "Rails") if defined?(Kernel::Rails)
81
+ Kernel.send(:remove_const, "ActionController") if defined?(Kernel::ActionController)
82
+ end
83
+
84
+ def fake_sinatra
85
+ Kernel.const_set("Sinatra", Module.new)
86
+ s = Kernel.const_get("Sinatra")
87
+ s.const_set("Base", Module.new)
88
+ end
89
+
90
+ def clean_fake_sinatra
91
+ Kernel.const_unset("Sinatra") if defined?(Kernel::Sinatra)
92
+ end
93
+
68
94
  # Helpers available to all tests
69
95
  class Minitest::Test
70
96
  def setup
@@ -29,32 +29,4 @@ class EnvironmentTest < Minitest::Test
29
29
  def test_framework_ruby
30
30
  assert_equal :ruby, ScoutApm::Environment.send(:new).framework
31
31
  end
32
-
33
- ############################################################
34
-
35
- def fake_rails(version)
36
- Kernel.const_set("Rails", Module.new)
37
- Kernel.const_set("ActionController", Module.new)
38
- r = Kernel.const_get("Rails")
39
- r.const_set("VERSION", Module.new)
40
- v = r.const_get("VERSION")
41
- v.const_set("MAJOR", version)
42
-
43
- assert_equal version, Rails::VERSION::MAJOR
44
- end
45
-
46
- def clean_fake_rails
47
- Kernel.send(:remove_const, "Rails") if defined?(Kernel::Rails)
48
- Kernel.send(:remove_const, "ActionController") if defined?(Kernel::ActionController)
49
- end
50
-
51
- def fake_sinatra
52
- Kernel.const_set("Sinatra", Module.new)
53
- s = Kernel.const_get("Sinatra")
54
- s.const_set("Base", Module.new)
55
- end
56
-
57
- def clean_fake_sinatra
58
- Kernel.const_unset("Sinatra") if defined?(Kernel::Sinatra)
59
- end
60
32
  end
@@ -24,6 +24,36 @@ class ActiveRecordTest < Minitest::Test
24
24
  class User < ActiveRecord::Base
25
25
  end
26
26
 
27
+ class DumbRailsConfig
28
+ def self.after_initialize; end
29
+ end
30
+
31
+ def test_old_rails_initialization
32
+ recorder = FakeRecorder.new
33
+ agent_context.recorder = recorder
34
+ old_rails_version = (1..2).to_a.sample
35
+ fake_rails(old_rails_version)
36
+
37
+ ::Rails.expects(:configuration).never
38
+
39
+ instrument = ScoutApm::Instruments::ActiveRecord.new(agent_context)
40
+ instrument.install(prepend: false)
41
+ clean_fake_rails
42
+ end
43
+
44
+ def test_modern_rails_initialization
45
+ recorder = FakeRecorder.new
46
+ agent_context.recorder = recorder
47
+ modern_rails_version = (3..7).to_a.sample
48
+ fake_rails(modern_rails_version)
49
+
50
+ ::Rails.expects(:configuration).returns(DumbRailsConfig).once
51
+
52
+ instrument = ScoutApm::Instruments::ActiveRecord.new(agent_context)
53
+ instrument.install(prepend: false)
54
+ clean_fake_rails
55
+ end
56
+
27
57
  def test_instrumentation
28
58
  recorder = FakeRecorder.new
29
59
  agent_context.recorder = recorder
@@ -1,23 +1,23 @@
1
1
  if (ENV["SCOUT_TEST_FEATURES"] || "").include?("instruments")
2
2
  require 'test_helper'
3
3
 
4
- require 'scout_apm/instruments/redis'
4
+ require 'scout_apm/instruments/redis5'
5
5
 
6
6
  require 'redis'
7
7
 
8
8
  class RedisTest < Minitest::Test
9
9
  def setup
10
10
  @context = ScoutApm::AgentContext.new
11
- @instance = ScoutApm::Instruments::Redis.new(@context)
11
+ @instance = ScoutApm::Instruments::Redis5.new(@context)
12
12
  @instrument_manager = ScoutApm::InstrumentManager.new(@context)
13
13
  @instance.install(prepend: @instrument_manager.prepend_for_instrument?(@instance.class))
14
14
  end
15
15
 
16
16
  def test_installs_using_proper_method
17
17
  if @instrument_manager.prepend_for_instrument?(@instance.class) == true
18
- assert ::Redis::Client.ancestors.include?(ScoutApm::Instruments::RedisClientInstrumentationPrepend)
18
+ assert ::Redis::Client.ancestors.include?(ScoutApm::Instruments::Redis5ClientInstrumentationPrepend)
19
19
  else
20
- assert_equal false, ::Redis::Client.ancestors.include?(ScoutApm::Instruments::RedisClientInstrumentationPrepend)
20
+ assert_equal false, ::Redis::Client.ancestors.include?(ScoutApm::Instruments::Redis5ClientInstrumentationPrepend)
21
21
  end
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.1
4
+ version: 5.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Haynes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-18 00:00:00.000000000 Z
12
+ date: 2023-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -319,6 +319,7 @@ files:
319
319
  - lib/scout_apm/instruments/process/process_memory.rb
320
320
  - lib/scout_apm/instruments/rails_router.rb
321
321
  - lib/scout_apm/instruments/redis.rb
322
+ - lib/scout_apm/instruments/redis5.rb
322
323
  - lib/scout_apm/instruments/resque.rb
323
324
  - lib/scout_apm/instruments/samplers.rb
324
325
  - lib/scout_apm/instruments/sinatra.rb
@@ -494,8 +495,72 @@ required_rubygems_version: !ruby/object:Gem::Requirement
494
495
  - !ruby/object:Gem::Version
495
496
  version: '0'
496
497
  requirements: []
497
- rubygems_version: 3.3.7
498
+ rubygems_version: 3.0.8
498
499
  signing_key:
499
500
  specification_version: 4
500
501
  summary: Ruby application performance monitoring
501
- test_files: []
502
+ test_files:
503
+ - test/data/config_test_1.yml
504
+ - test/test_helper.rb
505
+ - test/tmp/README.md
506
+ - test/unit/agent_context_test.rb
507
+ - test/unit/agent_test.rb
508
+ - test/unit/auto_instrument/anonymous_block_value.rb
509
+ - test/unit/auto_instrument/assignments-instrumented.rb
510
+ - test/unit/auto_instrument/assignments.rb
511
+ - test/unit/auto_instrument/controller-ast.txt
512
+ - test/unit/auto_instrument/controller-instrumented.rb
513
+ - test/unit/auto_instrument/controller.rb
514
+ - test/unit/auto_instrument/hanging_method.rb
515
+ - test/unit/auto_instrument/rescue_from-instrumented.rb
516
+ - test/unit/auto_instrument/rescue_from.rb
517
+ - test/unit/auto_instrument_test.rb
518
+ - test/unit/background_job_integrations/sidekiq_test.rb
519
+ - test/unit/config_test.rb
520
+ - test/unit/context_test.rb
521
+ - test/unit/db_query_metric_set_test.rb
522
+ - test/unit/db_query_metric_stats_test.rb
523
+ - test/unit/environment_test.rb
524
+ - test/unit/error_service/error_buffer_test.rb
525
+ - test/unit/error_service/ignored_exceptions_test.rb
526
+ - test/unit/extensions/periodic_callbacks_test.rb
527
+ - test/unit/extensions/transaction_callbacks_test.rb
528
+ - test/unit/external_service_metric_set_test.rb
529
+ - test/unit/external_service_metric_stats_test.rb
530
+ - test/unit/fake_store_test.rb
531
+ - test/unit/git_revision_test.rb
532
+ - test/unit/histogram_test.rb
533
+ - test/unit/ignored_uris_test.rb
534
+ - test/unit/instruments/active_record_test.rb
535
+ - test/unit/instruments/http_client_test.rb
536
+ - test/unit/instruments/http_test.rb
537
+ - test/unit/instruments/moped_test.rb
538
+ - test/unit/instruments/net_http_test.rb
539
+ - test/unit/instruments/percentile_sampler_test.rb
540
+ - test/unit/instruments/redis_test.rb
541
+ - test/unit/instruments/typhoeus_test.rb
542
+ - test/unit/layaway_test.rb
543
+ - test/unit/layer_children_set_test.rb
544
+ - test/unit/layer_converters/depth_first_walker_test.rb
545
+ - test/unit/layer_converters/metric_converter_test.rb
546
+ - test/unit/layer_converters/stubs.rb
547
+ - test/unit/limited_layer_test.rb
548
+ - test/unit/logger_test.rb
549
+ - test/unit/metric_set_test.rb
550
+ - test/unit/remote/message_test.rb
551
+ - test/unit/remote/route_test.rb
552
+ - test/unit/remote/server_test.rb
553
+ - test/unit/request_histograms_test.rb
554
+ - test/unit/scored_item_set_test.rb
555
+ - test/unit/serializers/payload_serializer_test.rb
556
+ - test/unit/slow_request_policy_test.rb
557
+ - test/unit/sql_sanitizer_test.rb
558
+ - test/unit/store_test.rb
559
+ - test/unit/tracer_test.rb
560
+ - test/unit/tracked_request_test.rb
561
+ - test/unit/transaction_test.rb
562
+ - test/unit/transaction_time_consumed_test.rb
563
+ - test/unit/utils/active_record_metric_name_test.rb
564
+ - test/unit/utils/backtrace_parser_test.rb
565
+ - test/unit/utils/numbers_test.rb
566
+ - test/unit/utils/scm.rb