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 +4 -4
- data/.github/workflows/test.yml +6 -0
- data/CHANGELOG.markdown +6 -1
- data/gems/rails7.gemfile +4 -0
- data/gems/sidekiq7.gemfile +3 -0
- data/gems/sidekiq8.gemfile +4 -0
- data/lib/scout_apm/auto_instrument/layer.rb +1 -0
- data/lib/scout_apm/error_service/sidekiq.rb +1 -1
- data/lib/scout_apm/git_revision.rb +7 -1
- data/lib/scout_apm/instruments/mongoid.rb +7 -35
- data/lib/scout_apm/tracked_request.rb +2 -0
- data/lib/scout_apm/version.rb +1 -1
- data/test/unit/background_job_integrations/sidekiq_test.rb +3 -1
- data/test/unit/config_test.rb +1 -1
- data/test/unit/git_revision_test.rb +65 -3
- data/test/unit/sampling_test.rb +4 -4
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6825b0cb6be5706305fa47b48fe8f84a89f0bf6019deb5914547d720e13db875
|
4
|
+
data.tar.gz: 5a5163d1c0f05f6ebe87aa0948e426b9332ff66121bc04c33048cad1ddef5e89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2853cef258799e5330896df9a6af7ee979eef4288e8853207ea150d9e4b6d176a4626570795692ab2faf7a6c4790d07eaa3d927e8e2143e53b304748c08558f
|
7
|
+
data.tar.gz: ec7d60860118f0e8b46e2ae3d147e1065d548d891706cfc26f1d4d45f47fdf87dce130dd62e75763fe01dacca79d32a1a1a485f8b5f9da8a843b2b239a693a85
|
data/.github/workflows/test.yml
CHANGED
@@ -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
|
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']).
|
data/gems/rails7.gemfile
ADDED
@@ -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
|
-
|
28
|
-
|
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
|
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 =~ /\
|
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
|
-
|
data/lib/scout_apm/version.rb
CHANGED
@@ -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.
|
21
|
+
::Sidekiq.configure_server do |config|
|
22
|
+
config[:lifecycle_events][:startup].map(&:call)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
data/test/unit/config_test.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
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
|
data/test/unit/sampling_test.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
44
|
+
assert_nil rate
|
45
45
|
|
46
46
|
rate = sampling.web_sample_rate('/baz/bap')
|
47
|
-
|
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
|
-
|
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.
|
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-
|
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
|