scout_apm 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +49 -0
- data/.rubocop.yml +2 -1
- data/.travis.yml +3 -1
- data/CHANGELOG.markdown +6 -0
- data/gems/rails6.gemfile +1 -1
- data/lib/scout_apm/environment.rb +16 -1
- data/lib/scout_apm/instruments/action_view.rb +18 -6
- data/lib/scout_apm/instruments/active_record.rb +5 -1
- data/lib/scout_apm/layer.rb +1 -1
- data/lib/scout_apm/remote/server.rb +13 -1
- data/lib/scout_apm/utils/sql_sanitizer_regex.rb +3 -3
- data/lib/scout_apm/version.rb +1 -1
- data/scout_apm.gemspec +1 -1
- data/test/unit/environment_test.rb +2 -2
- data/test/unit/sql_sanitizer_test.rb +31 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cce8f36675013a0c19a8fcc9c989c3cdb9ce200dbd9d80910ba0f1581a69e6b
|
4
|
+
data.tar.gz: adebeda03d35f00f36f0db73e78a205bd90646f6ab005270660cf7d86a4b685f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9fc58ab95c94e5d904bc3b04c5d0a37be1cecb965d88cf994a652e46542457d298759f0a8cfce4040def439d77970a04f35d258b2b96546354ef46b93da42e
|
7
|
+
data.tar.gz: f1ab27e4646ccaa8a11220aff213d239b61434f2e511584e560c5234beec9b1746801a53898b49136097c814f726cf31b4d2dafbcaaf928910cd2204f51b5a84
|
@@ -0,0 +1,49 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
lint:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
- uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
bundler-cache: true
|
14
|
+
ruby-version: 2.6
|
15
|
+
- run: bundle exec rubocop
|
16
|
+
|
17
|
+
test:
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
include:
|
22
|
+
- ruby: 2.1
|
23
|
+
gemfile: gems/rails3.gemfile
|
24
|
+
- ruby: 2.2
|
25
|
+
- ruby: 2.3
|
26
|
+
- ruby: 2.4
|
27
|
+
- ruby: 2.5
|
28
|
+
- ruby: 2.6
|
29
|
+
- ruby: 2.6
|
30
|
+
gemfile: gems/octoshark.gemfile
|
31
|
+
- ruby: 2.6
|
32
|
+
gemfile: gems/rails3.gemfile
|
33
|
+
bundler: 1.17.3
|
34
|
+
- ruby: 2.7
|
35
|
+
- ruby: 3.0
|
36
|
+
|
37
|
+
env:
|
38
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
39
|
+
|
40
|
+
runs-on: ubuntu-latest
|
41
|
+
|
42
|
+
steps:
|
43
|
+
- uses: actions/checkout@v2
|
44
|
+
- uses: ruby/setup-ruby@v1
|
45
|
+
with:
|
46
|
+
bundler-cache: true
|
47
|
+
bundler: ${{matrix.bundler}}
|
48
|
+
ruby-version: ${{ matrix.ruby }}
|
49
|
+
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -4,9 +4,10 @@ AllCops:
|
|
4
4
|
Exclude:
|
5
5
|
- 'test/unit/auto_instrument/*'
|
6
6
|
- vendor/bundle/**/*
|
7
|
+
SuggestExtensions: false
|
7
8
|
|
8
9
|
# 80 is stifling, especially with a few levels of nesting before we even start.
|
9
10
|
# So bump it to 100 to keep really long lines from creeping in.
|
10
|
-
|
11
|
+
Layout/LineLength:
|
11
12
|
Enabled: false
|
12
13
|
Max: 100
|
data/.travis.yml
CHANGED
data/CHANGELOG.markdown
CHANGED
data/gems/rails6.gemfile
CHANGED
@@ -182,9 +182,24 @@ module ScoutApm
|
|
182
182
|
@ruby_2 = defined?(RUBY_VERSION) && RUBY_VERSION.match(/^2/)
|
183
183
|
end
|
184
184
|
|
185
|
+
def ruby_3?
|
186
|
+
return @ruby_3 if defined?(@ruby_3)
|
187
|
+
@ruby_3 = defined?(RUBY_VERSION) && RUBY_VERSION.match(/^3/)
|
188
|
+
end
|
189
|
+
|
190
|
+
def ruby_minor
|
191
|
+
return @ruby_minor if defined?(@ruby_minor)
|
192
|
+
@ruby_minor = defined?(RUBY_VERSION) && RUBY_VERSION.split(".")[1].to_i
|
193
|
+
end
|
194
|
+
|
185
195
|
# Returns true if this Ruby version supports Module#prepend.
|
186
196
|
def supports_module_prepend?
|
187
|
-
ruby_2?
|
197
|
+
ruby_2? || ruby_3?
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns true if this Ruby version supports Module#prepend.
|
201
|
+
def supports_kwarg_delegation?
|
202
|
+
ruby_3? || (ruby_2? && ruby_minor >= 7)
|
188
203
|
end
|
189
204
|
|
190
205
|
# Returns a string representation of the OS (ex: darwin, linux)
|
@@ -77,7 +77,7 @@ module ScoutApm
|
|
77
77
|
module ActionViewPartialRendererInstruments
|
78
78
|
# In Rails 6, the signature changed to pass the view & template args directly, as opposed to through the instance var
|
79
79
|
# New signature is: def render_partial(view, template)
|
80
|
-
def render_partial(*args)
|
80
|
+
def render_partial(*args, **kwargs)
|
81
81
|
req = ScoutApm::RequestManager.lookup
|
82
82
|
|
83
83
|
maybe_template = args[1]
|
@@ -92,13 +92,17 @@ module ScoutApm
|
|
92
92
|
|
93
93
|
begin
|
94
94
|
req.start_layer(layer)
|
95
|
-
|
95
|
+
if ScoutApm::Agent.instance.context.environment.supports_kwarg_delegation?
|
96
|
+
super(*args, **kwargs)
|
97
|
+
else
|
98
|
+
super(*args)
|
99
|
+
end
|
96
100
|
ensure
|
97
101
|
req.stop_layer
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
101
|
-
def collection_with_template(*args)
|
105
|
+
def collection_with_template(*args, **kwargs)
|
102
106
|
req = ScoutApm::RequestManager.lookup
|
103
107
|
|
104
108
|
template_name = @template.virtual_path rescue "Unknown Collection"
|
@@ -110,7 +114,11 @@ module ScoutApm
|
|
110
114
|
|
111
115
|
begin
|
112
116
|
req.start_layer(layer)
|
113
|
-
|
117
|
+
if ScoutApm::Agent.instance.context.environment.supports_kwarg_delegation?
|
118
|
+
super(*args, **kwargs)
|
119
|
+
else
|
120
|
+
super(*args)
|
121
|
+
end
|
114
122
|
ensure
|
115
123
|
req.stop_layer
|
116
124
|
end
|
@@ -118,7 +126,7 @@ module ScoutApm
|
|
118
126
|
end
|
119
127
|
|
120
128
|
module ActionViewTemplateRendererInstruments
|
121
|
-
def render_template(*args)
|
129
|
+
def render_template(*args, **kwargs)
|
122
130
|
req = ScoutApm::RequestManager.lookup
|
123
131
|
|
124
132
|
template_name = args[0].virtual_path rescue "Unknown"
|
@@ -130,7 +138,11 @@ module ScoutApm
|
|
130
138
|
|
131
139
|
begin
|
132
140
|
req.start_layer(layer)
|
133
|
-
|
141
|
+
if ScoutApm::Agent.instance.context.environment.supports_kwarg_delegation?
|
142
|
+
super(*args, **kwargs)
|
143
|
+
else
|
144
|
+
super(*args)
|
145
|
+
end
|
134
146
|
ensure
|
135
147
|
req.stop_layer
|
136
148
|
end
|
@@ -315,7 +315,11 @@ module ScoutApm
|
|
315
315
|
req.start_layer(layer)
|
316
316
|
req.ignore_children!
|
317
317
|
begin
|
318
|
-
|
318
|
+
if ScoutApm::Agent.instance.context.environment.supports_kwarg_delegation?
|
319
|
+
find_by_sql_without_scout_instruments(*args, **kwargs, &block)
|
320
|
+
else
|
321
|
+
find_by_sql_without_scout_instruments(*args, &block)
|
322
|
+
end
|
319
323
|
ensure
|
320
324
|
req.acknowledge_children!
|
321
325
|
req.stop_layer
|
data/lib/scout_apm/layer.rb
CHANGED
@@ -116,7 +116,7 @@ module ScoutApm
|
|
116
116
|
# In Ruby 2.0+, we can pass the range directly to the caller to reduce the memory footprint.
|
117
117
|
def caller_array
|
118
118
|
# omits the first several callers which are in the ScoutAPM stack.
|
119
|
-
if ScoutApm::Agent.instance.context.environment.ruby_2?
|
119
|
+
if ScoutApm::Agent.instance.context.environment.ruby_2? || ScoutApm::Agent.instance.context.environment.ruby_3?
|
120
120
|
caller(3...BACKTRACE_CALLER_LIMIT)
|
121
121
|
else
|
122
122
|
caller[3...BACKTRACE_CALLER_LIMIT]
|
@@ -16,8 +16,20 @@ module ScoutApm
|
|
16
16
|
@server = nil
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def require_webrick
|
20
20
|
require 'webrick'
|
21
|
+
true
|
22
|
+
rescue LoadError
|
23
|
+
@logger.warn(
|
24
|
+
%q|Could not require Webrick. Ruby 3.0 stopped bundling it
|
25
|
+
automatically, but it is required to instrument Resque. Please add
|
26
|
+
Webrick to your Gemfile.|
|
27
|
+
)
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def start
|
32
|
+
return false unless require_webrick
|
21
33
|
|
22
34
|
@server = WEBrick::HTTPServer.new(
|
23
35
|
:BindAddress => bind,
|
@@ -5,13 +5,13 @@ module ScoutApm
|
|
5
5
|
MULTIPLE_SPACES = %r|\s+|.freeze
|
6
6
|
MULTIPLE_QUESTIONS = /\?(,\?)+/.freeze
|
7
7
|
|
8
|
-
PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s
|
8
|
+
PSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*\z|.freeze
|
9
9
|
PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
10
10
|
PSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
11
11
|
PSQL_PLACEHOLDER = /\$\d+/.freeze
|
12
12
|
PSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
13
|
-
PSQL_AFTER_WHERE = /(?:WHERE\s+).*?(?:SELECT
|
14
|
-
PSQL_AFTER_SET = /(?:SET\s+).*?(?:WHERE
|
13
|
+
PSQL_AFTER_WHERE = /(?:WHERE\s+).*?(?:SELECT|\z)/im.freeze
|
14
|
+
PSQL_AFTER_SET = /(?:SET\s+).*?(?:WHERE|\z)/im.freeze
|
15
15
|
|
16
16
|
MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
17
17
|
MYSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
data/lib/scout_apm/version.rb
CHANGED
data/scout_apm.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.extensions << 'ext/allocations/extconf.rb'
|
22
22
|
s.extensions << 'ext/rusage/extconf.rb'
|
23
23
|
|
24
|
-
s.required_ruby_version = '
|
24
|
+
s.required_ruby_version = '>= 2.1'
|
25
25
|
|
26
26
|
s.add_development_dependency "minitest"
|
27
27
|
s.add_development_dependency "mocha"
|
@@ -44,8 +44,8 @@ class EnvironmentTest < Minitest::Test
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def clean_fake_rails
|
47
|
-
Kernel.
|
48
|
-
Kernel.
|
47
|
+
Kernel.send(:remove_const, "Rails") if defined?(Kernel::Rails)
|
48
|
+
Kernel.send(:remove_const, "ActionController") if defined?(Kernel::ActionController)
|
49
49
|
end
|
50
50
|
|
51
51
|
def fake_sinatra
|
@@ -146,6 +146,37 @@ module ScoutApm
|
|
146
146
|
assert_equal %q|UPDATE "mytable" SET "myfield" = ?, "countofthings" = ? WHERE "user_id" = ?|, ss.to_s
|
147
147
|
end
|
148
148
|
|
149
|
+
def test_postgres_multiline_sql
|
150
|
+
sql = %q|
|
151
|
+
SELECT "html_form_payloads".*
|
152
|
+
FROM "html_form_payloads"
|
153
|
+
INNER JOIN "leads" ON "leads"."payload_id" = "html_form_payloads"."id"
|
154
|
+
AND "leads"."payload_type" = ?
|
155
|
+
WHERE html_form_payloads.id < 10
|
156
|
+
AND "form_type" = 'xyz'
|
157
|
+
AND (params::varchar = '{"name":"Chris","resident":"Yes","e-content":"Secret content"}')
|
158
|
+
AND (leads.url = 'http://example.com')
|
159
|
+
ORDER BY "html_form_payloads"."id" ASC
|
160
|
+
LIMIT ?
|
161
|
+
|
|
162
|
+
|
163
|
+
ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :postgres }
|
164
|
+
assert_equal %q|SELECT "html_form_payloads".* FROM "html_form_payloads" INNER JOIN "leads" ON "leads"."payload_id" = "html_form_payloads"."id" AND "leads"."payload_type" = ? WHERE html_form_payloads.id < ? AND "form_type" = ? AND (params::varchar = ?) AND (leads.url = ?) ORDER BY "html_form_payloads"."id" ASC LIMIT ?|, ss.to_s
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_mysql_multiline
|
168
|
+
sql = %q|
|
169
|
+
SELECT `blogs`.*
|
170
|
+
FROM `blogs`
|
171
|
+
WHERE (title = 'abc')
|
172
|
+
|
|
173
|
+
|
174
|
+
ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :mysql }
|
175
|
+
assert_equal %q|SELECT `blogs`.*
|
176
|
+
FROM `blogs`
|
177
|
+
WHERE (title = ?)|, ss.to_s
|
178
|
+
end
|
179
|
+
|
149
180
|
def assert_faster_than(target_seconds)
|
150
181
|
t1 = ::Time.now
|
151
182
|
yield
|
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: 4.0.
|
4
|
+
version: 4.0.1
|
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:
|
12
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -216,6 +216,7 @@ extensions:
|
|
216
216
|
- ext/rusage/extconf.rb
|
217
217
|
extra_rdoc_files: []
|
218
218
|
files:
|
219
|
+
- ".github/workflows/test.yml"
|
219
220
|
- ".gitignore"
|
220
221
|
- ".rubocop.yml"
|
221
222
|
- ".travis.yml"
|
@@ -468,7 +469,7 @@ require_paths:
|
|
468
469
|
- data
|
469
470
|
required_ruby_version: !ruby/object:Gem::Requirement
|
470
471
|
requirements:
|
471
|
-
- - "
|
472
|
+
- - ">="
|
472
473
|
- !ruby/object:Gem::Version
|
473
474
|
version: '2.1'
|
474
475
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -477,7 +478,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
477
478
|
- !ruby/object:Gem::Version
|
478
479
|
version: '0'
|
479
480
|
requirements: []
|
480
|
-
rubygems_version: 3.
|
481
|
+
rubygems_version: 3.1.2
|
481
482
|
signing_key:
|
482
483
|
specification_version: 4
|
483
484
|
summary: Ruby application performance monitoring
|