scout_apm 5.6.1 → 5.6.2

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: 351ed300191874b86b1c402a2696897d05006266c2c88716a15d8588aefa00b2
4
- data.tar.gz: dcdc4fb47007eb665f7a4df6a3a9a7bcde78550656692fc5023020739b0974d9
3
+ metadata.gz: 6825b0cb6be5706305fa47b48fe8f84a89f0bf6019deb5914547d720e13db875
4
+ data.tar.gz: 5a5163d1c0f05f6ebe87aa0948e426b9332ff66121bc04c33048cad1ddef5e89
5
5
  SHA512:
6
- metadata.gz: 8fe62cd0646f58ad535d3912cf9c023fb8d7c52116dd30b3359e7f33f50f51ba3457090fe2df8f0bec5e5194b02bcccb44feaa466d76fa14938b91f11f1f74c0
7
- data.tar.gz: cd20a788b47c33be24c8ee88eb00d443bf3d20990ba3fb769ca64353b14b090b931c121d6f07aa40bd366381f3f77646b41206e66cb9507cb204ee3eaadf62fe
6
+ metadata.gz: d2853cef258799e5330896df9a6af7ee979eef4288e8853207ea150d9e4b6d176a4626570795692ab2faf7a6c4790d07eaa3d927e8e2143e53b304748c08558f
7
+ data.tar.gz: ec7d60860118f0e8b46e2ae3d147e1065d548d891706cfc26f1d4d45f47fdf87dce130dd62e75763fe01dacca79d32a1a1a485f8b5f9da8a843b2b239a693a85
@@ -42,6 +42,12 @@ jobs:
42
42
  - ruby: "3.0"
43
43
  gemfile: gems/sidekiq.gemfile
44
44
  test_features: "sidekiq_install"
45
+ - ruby: "3.0"
46
+ gemfile: gems/sidekiq7.gemfile
47
+ test_features: "sidekiq_install"
48
+ - ruby: "3.3"
49
+ gemfile: gems/sidekiq8.gemfile
50
+ test_features: "sidekiq_install"
45
51
  - ruby: 3.1
46
52
  - ruby: 3.2
47
53
  gemfile: gems/sqlite3-v2.gemfile
data/CHANGELOG.markdown CHANGED
@@ -1,10 +1,15 @@
1
1
  # Unreleased
2
2
 
3
+ # 5.6.2
4
+ - Fix deprecation warning for Sidekiq 7.1.5+ (#535)
5
+ - Add support for Mongoid 8 and 9. Remove support for old versions. (#538)
6
+ - Detect deployed SHA from Kamal (#528)
7
+
3
8
  # 5.6.1
4
9
  - Fix `job_sample_rate` and `endpoint_sample_rate` default configuration values (#529)
5
10
 
6
11
  # 5.6.0
7
- - New options for sampling and ignore configurationn (#521)
12
+ - New options for sampling and ignore configuration (#521)
8
13
  - `sample_rate` - Set the rate at which requests are sampled globally (1-100, a percentage of requests to keep).
9
14
  - `ignore_endpoints` - Ignore endpoints by regex matching prefix (Same as and replaces `ignore`)
10
15
  - `sample_endpoints` - Sample endpoints by regex matching prefix (i.e. ['/foo:70']).
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 7.0"
4
+ gem "sqlite3", "~> 1.4"
@@ -0,0 +1,3 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem 'sidekiq', '~> 7.0'
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem 'sqlite3', '~> 2.0'
4
+ gem 'sidekiq', '~> 8.0'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module ScoutApm
3
4
  def self.AutoInstrument(name, backtrace)
@@ -28,7 +28,7 @@ module ScoutApm
28
28
 
29
29
  def install_sidekiq_with_error_handler
30
30
  ::Sidekiq.configure_server do |config|
31
- config.error_handlers << proc { |exception, job_info|
31
+ config.error_handlers << proc { |exception, job_info, sidekiq_config|
32
32
  context = ScoutApm::Agent.instance.context
33
33
 
34
34
  # Bail out early, and reraise if the error is not interesting.
@@ -20,6 +20,7 @@ module ScoutApm
20
20
  detect_from_config ||
21
21
  detect_from_heroku ||
22
22
  detect_from_capistrano ||
23
+ detect_from_kamal ||
23
24
  detect_from_mina ||
24
25
  detect_from_git
25
26
  end
@@ -44,8 +45,13 @@ module ScoutApm
44
45
  nil
45
46
  end
46
47
 
48
+ # https://github.com/basecamp/kamal
49
+ def detect_from_kamal
50
+ ENV['KAMAL_VERSION']
51
+ end
52
+
47
53
  # https://github.com/mina-deploy/mina
48
- def detect_from_mina
54
+ def detect_from_mina
49
55
  File.read(File.join(app_root, '.mina_git_revision')).strip
50
56
  rescue
51
57
  logger.debug "Unable to detect Git Revision from Mina: #{$!.message}"
@@ -20,25 +20,12 @@ module ScoutApm
20
20
  @installed = true
21
21
 
22
22
  # Mongoid versions that use Moped should instrument Moped.
23
+ ### See moped instrument for Moped driven deploys
23
24
  if defined?(::Mongoid) and !defined?(::Moped)
24
- logger.info "Instrumenting Mongoid 2.x"
25
25
  @installed = true
26
26
 
27
- ### OLD (2.x) mongoids
28
- if defined?(::Mongoid::Collection)
29
- ::Mongoid::Collection.class_eval do
30
- include ScoutApm::Tracer
31
- (::Mongoid::Collections::Operations::ALL - [:<<, :[]]).each do |method|
32
- instrument_method method, :type => "MongoDB", :name => '#{@klass}/' + method.to_s
33
- end
34
- end
35
- end
36
-
37
- ### See moped instrument for Moped driven deploys
38
-
39
- ### 5.x Mongoid
40
- if (mongoid_v5? || mongoid_v6? || mongoid_v7?) && defined?(::Mongoid::Contextual::Mongo)
41
- logger.info "Instrumenting Mongoid 5.x/6.x/7.x"
27
+ if (mongoid_at_least_5?) && defined?(::Mongoid::Contextual::Mongo)
28
+ logger.info "Instrumenting Mongoid"
42
29
  # All the public methods from Mongoid::Contextual::Mongo.
43
30
  # TODO: Geo and MapReduce support (?). They are in other Contextual::* classes
44
31
  methods = [
@@ -88,31 +75,17 @@ module ScoutApm
88
75
  ]
89
76
 
90
77
  ::Mongoid::Contextual::Mongo.class_eval(with_scout_instruments)
78
+ else
79
+ logger.warn "Expected method #{method} not defined in Mongoid::Contextual::Mongo."
91
80
  end
92
81
  end
93
82
  end
94
83
  end
95
84
  end
96
85
 
97
- def mongoid_v5?
98
- if defined?(::Mongoid::VERSION)
99
- ::Mongoid::VERSION =~ /\A5/
100
- else
101
- false
102
- end
103
- end
104
-
105
- def mongoid_v6?
86
+ def mongoid_at_least_5?
106
87
  if defined?(::Mongoid::VERSION)
107
- ::Mongoid::VERSION =~ /\A6/
108
- else
109
- false
110
- end
111
- end
112
-
113
- def mongoid_v7?
114
- if defined?(::Mongoid::VERSION)
115
- ::Mongoid::VERSION =~ /\A7/
88
+ ::Mongoid::VERSION =~ /\A[56789]/
116
89
  else
117
90
  false
118
91
  end
@@ -134,4 +107,3 @@ module ScoutApm
134
107
  end
135
108
  end
136
109
  end
137
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A TrackedRequest is a stack of layers, where completed layers (go into, then
2
4
  # come out of a layer) are forgotten as they finish. Layers are attached to
3
5
  # their children as the process goes, building a tree structure within the
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "5.6.1"
2
+ VERSION = "5.6.2"
3
3
  end
@@ -18,7 +18,9 @@ class SidekiqTest < Minitest::Test
18
18
  def test_starts_on_startup
19
19
  ::ScoutApm::Agent.any_instance.expects(:start)
20
20
  SidekiqIntegration.new.install
21
- Sidekiq.options[:lifecycle_events][:startup].map(&:call)
21
+ ::Sidekiq.configure_server do |config|
22
+ config[:lifecycle_events][:startup].map(&:call)
23
+ end
22
24
  end
23
25
  end
24
26
 
@@ -89,7 +89,7 @@ class ConfigTest < Minitest::Test
89
89
  assert_equal 0, coercion.coerce("0")
90
90
  assert_equal 0, coercion.coerce(0)
91
91
  assert_equal 0, coercion.coerce("")
92
- assert_equal nil, coercion.coerce(nil)
92
+ assert_nil coercion.coerce(nil)
93
93
  end
94
94
 
95
95
  def test_any_keys_found
@@ -3,13 +3,75 @@ require 'test_helper'
3
3
  require 'scout_apm/git_revision'
4
4
 
5
5
  class GitRevisionTest < Minitest::Test
6
- # TODO - other tests that would be nice:
7
- # * ensure we only detect once, on initialize.
8
- # * tests for reading cap files
6
+ def setup
7
+ @env = ENV.to_h
8
+ end
9
+
10
+ def teardown
11
+ ENV.replace(@env)
12
+ end
13
+
14
+ def test_sha_detected_once
15
+ ENV['HEROKU_SLUG_COMMIT'] = 'initial_slug'
16
+ revision = ScoutApm::GitRevision.new(ScoutApm::AgentContext.new)
17
+ assert_equal 'initial_slug', revision.sha
18
+
19
+ ENV['HEROKU_SLUG_COMMIT'] = 'new_slug'
20
+ assert_equal 'initial_slug', revision.sha
21
+ end
22
+
23
+ def test_sha_from_config
24
+ config = make_fake_config('revision_sha' => 'config_sha')
25
+ context = ScoutApm::AgentContext.new().tap { |c| c.config = config }
26
+ revision = ScoutApm::GitRevision.new(context)
27
+
28
+ assert_equal 'config_sha', revision.sha
29
+ end
9
30
 
10
31
  def test_sha_from_heroku
11
32
  ENV['HEROKU_SLUG_COMMIT'] = 'heroku_slug'
12
33
  revision = ScoutApm::GitRevision.new(ScoutApm::AgentContext.new)
13
34
  assert_equal 'heroku_slug', revision.sha
14
35
  end
36
+
37
+ def test_sha_from_capistrano
38
+ Dir.mktmpdir do |dir|
39
+ context = context_with_file_in_root(File.join(dir, 'REVISION'), 'capistrano_sha')
40
+ revision = ScoutApm::GitRevision.new(context)
41
+ assert_equal 'capistrano_sha', revision.sha
42
+ end
43
+ end
44
+
45
+ def test_sha_from_kamal
46
+ ENV['KAMAL_VERSION'] = 'kamal_sha'
47
+ revision = ScoutApm::GitRevision.new(ScoutApm::AgentContext.new)
48
+ assert_equal 'kamal_sha', revision.sha
49
+ end
50
+
51
+
52
+ def test_sha_from_mina
53
+ Dir.mktmpdir do |dir|
54
+ context = context_with_file_in_root(File.join(dir, '.mina_git_revision'), 'mina_sha')
55
+ revision = ScoutApm::GitRevision.new(context)
56
+ assert_equal 'mina_sha', revision.sha
57
+ end
58
+ end
59
+
60
+ def test_sha_from_git
61
+ short_sha = `git rev-parse --short HEAD`.strip
62
+ skip 'git not installed or not in a git repository' if short_sha.empty?
63
+
64
+ revision = ScoutApm::GitRevision.new(ScoutApm::AgentContext.new)
65
+ assert_equal short_sha, revision.sha
66
+ end
67
+
68
+ private
69
+
70
+ def context_with_file_in_root(file_name, contents)
71
+ config = make_fake_config({})
72
+ env = make_fake_environment(root: File.dirname(file_name))
73
+ File.write(file_name, contents)
74
+
75
+ ScoutApm::AgentContext.new().tap { |c| c.config = config; c.environment = env }
76
+ end
15
77
  end
@@ -26,7 +26,7 @@ class SamplingTest < Minitest::Test
26
26
  assert_equal({'/foo/bar' => 100, '/foo' => 50, '/bar/zap' => 80}, sampling.individual_sample_to_hash(@individual_config.value('sample_endpoints')))
27
27
 
28
28
  sampling = ScoutApm::Sampling.new(@global_sample_config)
29
- assert_equal nil, sampling.individual_sample_to_hash(@global_sample_config.value('sample_endpoints'))
29
+ assert_nil sampling.individual_sample_to_hash(@global_sample_config.value('sample_endpoints'))
30
30
  end
31
31
 
32
32
  def test_uri_ignore
@@ -41,10 +41,10 @@ class SamplingTest < Minitest::Test
41
41
  assert_equal 50, rate
42
42
 
43
43
  rate = sampling.web_sample_rate('/bar')
44
- assert_equal nil, rate
44
+ assert_nil rate
45
45
 
46
46
  rate = sampling.web_sample_rate('/baz/bap')
47
- assert_equal nil, rate
47
+ assert_nil rate
48
48
 
49
49
  rate = sampling.web_sample_rate('/foo/bar/baz')
50
50
  assert_equal 100, rate
@@ -59,7 +59,7 @@ class SamplingTest < Minitest::Test
59
59
  def test_job_sample
60
60
  sampling = ScoutApm::Sampling.new(@individual_config)
61
61
  assert_equal 50, sampling.job_sample_rate('joba')
62
- assert_equal nil, sampling.job_sample_rate('jobb')
62
+ assert_nil sampling.job_sample_rate('jobb')
63
63
  end
64
64
 
65
65
  def test_sample
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.1
4
+ version: 5.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Haynes
8
8
  - Andre Lewis
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-21 00:00:00.000000000 Z
11
+ date: 2025-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -238,7 +238,10 @@ files:
238
238
  - gems/rails4.gemfile
239
239
  - gems/rails5.gemfile
240
240
  - gems/rails6.gemfile
241
+ - gems/rails7.gemfile
241
242
  - gems/sidekiq.gemfile
243
+ - gems/sidekiq7.gemfile
244
+ - gems/sidekiq8.gemfile
242
245
  - gems/sqlite3-v2.gemfile
243
246
  - gems/typhoeus.gemfile
244
247
  - lib/scout_apm.rb