scout_apm 2.6.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +6 -0
- data/Gemfile +1 -0
- data/lib/scout_apm/auto_instrument/layer.rb +3 -1
- data/lib/scout_apm/auto_instrument/rails.rb +5 -1
- data/lib/scout_apm/periodic_work.rb +10 -5
- data/lib/scout_apm/request_histograms.rb +5 -1
- data/lib/scout_apm/version.rb +1 -1
- data/test/unit/auto_instrument/assignments-instrumented.rb +16 -11
- data/test/unit/auto_instrument/assignments.rb +5 -0
- data/test/unit/auto_instrument/controller-instrumented.rb +14 -14
- data/test/unit/auto_instrument_test.rb +6 -3
- data/test/unit/request_histograms_test.rb +17 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfac08a037b046a0775634ea7ba351a9e3310c3eb4ea3bedd0571bead3984379
|
4
|
+
data.tar.gz: 4218e6a354d14dfc920cf34f86dd556c25e2fe8be04f78d43963ea00ad7ec9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87aa046c482068c6bd85c14fa9550796099fb6517fd17eeb10888f61d6ccd4ed724e51deb57c6c9598d556f5f7f48a4faed4457d4c2c0e6d4eaf97c66e4004df
|
7
|
+
data.tar.gz: ac15c172111160f119c56cae0bdd6494704b481bb02a22a97cd5d373fafa3e5d747039c412b3bc50cf0e1f293b0c32542fbbd8a2547cdbbaf918898f5c382901
|
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 2.6.2
|
2
|
+
|
3
|
+
* Fix Autoinstruments logging when running without ActiveSupport (#290)
|
4
|
+
* Fix edge-case Autoinstruments syntax error (#287)
|
5
|
+
* Fix invalid syntax for running on Ruby 1.8.7
|
6
|
+
|
1
7
|
# 2.6.1
|
2
8
|
|
3
9
|
* Logging total autoinstrumented spans and the ratio of significant to total spans (#283).
|
data/Gemfile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
|
2
2
|
module ScoutApm
|
3
|
-
def self.AutoInstrument(name, backtrace
|
3
|
+
def self.AutoInstrument(name, backtrace)
|
4
4
|
request = ScoutApm::RequestManager.lookup
|
5
5
|
|
6
|
+
file_name, _ = backtrace.first.split(":", 2)
|
7
|
+
|
6
8
|
begin
|
7
9
|
layer = ScoutApm::Layer.new('AutoInstrument', name)
|
8
10
|
layer.backtrace = backtrace
|
@@ -73,7 +73,7 @@ module ScoutApm
|
|
73
73
|
bt = ["#{file_name}:#{line}:in `#{method_name}'"]
|
74
74
|
|
75
75
|
return [
|
76
|
-
"::ScoutApm::AutoInstrument("+ source.dump + ",#{bt}
|
76
|
+
"::ScoutApm::AutoInstrument("+ source.dump + ",#{bt}){",
|
77
77
|
"}"
|
78
78
|
]
|
79
79
|
end
|
@@ -102,6 +102,10 @@ module ScoutApm
|
|
102
102
|
return
|
103
103
|
end
|
104
104
|
|
105
|
+
def on_op_asgn(node)
|
106
|
+
process(node.children[2])
|
107
|
+
end
|
108
|
+
|
105
109
|
def on_or_asgn(node)
|
106
110
|
process(node.children[1])
|
107
111
|
end
|
@@ -12,19 +12,24 @@ module ScoutApm
|
|
12
12
|
ScoutApm::Debug.instance.call_periodic_hooks
|
13
13
|
@reporting.process_metrics
|
14
14
|
clean_old_percentiles
|
15
|
-
|
15
|
+
|
16
|
+
if context.config.value('auto_instruments')
|
17
|
+
log_autoinstrument_significant_counts rescue nil
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
private
|
19
22
|
|
20
|
-
def
|
23
|
+
def log_autoinstrument_significant_counts
|
21
24
|
# Ex key/value -
|
22
25
|
# "/Users/dlite/projects/scout/apm/app/controllers/application_controller.rb"=>[[0.0, 689], [1.0, 16]]
|
23
26
|
hists = context.auto_instruments_layer_histograms.as_json
|
24
|
-
hists_summary = hists.map { |
|
27
|
+
hists_summary = hists.map { |file, buckets|
|
28
|
+
total = buckets.map(&:last).inject(0) { |sum, count| sum + count }
|
29
|
+
significant = (buckets.last.last / total.to_f).round(2)
|
25
30
|
[
|
26
|
-
|
27
|
-
{:total => total
|
31
|
+
file,
|
32
|
+
{:total => total, :significant => significant}
|
28
33
|
]
|
29
34
|
}.to_h
|
30
35
|
context.logger.debug("AutoInstrument Significant Layer Histograms: #{hists_summary.pretty_inspect}")
|
data/lib/scout_apm/version.rb
CHANGED
@@ -1,26 +1,31 @@
|
|
1
1
|
|
2
2
|
class Assignments
|
3
|
+
def test_op_asgn
|
4
|
+
foo.bar += ::ScoutApm::AutoInstrument("User.size",["ROOT/test/unit/auto_instrument/assignments.rb:4:in `test_op_asgn'"]){User.size}
|
5
|
+
foo.bar -= ::ScoutApm::AutoInstrument("User.size",["ROOT/test/unit/auto_instrument/assignments.rb:5:in `test_op_asgn'"]){User.size}
|
6
|
+
end
|
7
|
+
|
3
8
|
def nested_assignment
|
4
|
-
@email ||= if (email = ::ScoutApm::AutoInstrument("session[\"email\"]",["
|
5
|
-
::ScoutApm::AutoInstrument("User.where(email: email).first",["
|
9
|
+
@email ||= if (email = ::ScoutApm::AutoInstrument("session[\"email\"]",["ROOT/test/unit/auto_instrument/assignments.rb:9:in `nested_assignment'"]){session["email"]}).present?
|
10
|
+
::ScoutApm::AutoInstrument("User.where(email: email).first",["ROOT/test/unit/auto_instrument/assignments.rb:10:in `nested_assignment'"]){User.where(email: email).first}
|
6
11
|
else
|
7
12
|
nil
|
8
13
|
end
|
9
14
|
end
|
10
15
|
|
11
16
|
def paginate_collection(coll)
|
12
|
-
page = (::ScoutApm::AutoInstrument("params[:page].present?",["
|
13
|
-
per_page = (::ScoutApm::AutoInstrument("params[:per_page].present?",["
|
14
|
-
pagination, self.collection = ::ScoutApm::AutoInstrument("pagy(...",["
|
17
|
+
page = (::ScoutApm::AutoInstrument("params[:page].present?",["ROOT/test/unit/auto_instrument/assignments.rb:17:in `paginate_collection'"]){params[:page].present?} ? ::ScoutApm::AutoInstrument("params[:page].to_i",["ROOT/test/unit/auto_instrument/assignments.rb:17:in `paginate_collection'"]){params[:page].to_i} : 1)
|
18
|
+
per_page = (::ScoutApm::AutoInstrument("params[:per_page].present?",["ROOT/test/unit/auto_instrument/assignments.rb:18:in `paginate_collection'"]){params[:per_page].present?} ? ::ScoutApm::AutoInstrument("params[:per_page].to_i",["ROOT/test/unit/auto_instrument/assignments.rb:18:in `paginate_collection'"]){params[:per_page].to_i} : 20)
|
19
|
+
pagination, self.collection = ::ScoutApm::AutoInstrument("pagy(...",["ROOT/test/unit/auto_instrument/assignments.rb:19:in `paginate_collection'"]){pagy(
|
15
20
|
coll,
|
16
21
|
items: per_page,
|
17
22
|
page: page
|
18
23
|
)}
|
19
|
-
::ScoutApm::AutoInstrument("headers[PAGINATION_TOTAL_HEADER] = pagination.count.to_s",["
|
20
|
-
::ScoutApm::AutoInstrument("headers[PAGINATION_TOTAL_PAGES_HEADER] = pagination.pages.to_s",["
|
21
|
-
::ScoutApm::AutoInstrument("headers[PAGINATION_PER_PAGE_HEADER] = per_page.to_s",["
|
22
|
-
::ScoutApm::AutoInstrument("headers[PAGINATION_PAGE_HEADER] = pagination.page.to_s",["
|
23
|
-
::ScoutApm::AutoInstrument("headers[PAGINATION_NEXT_PAGE_HEADER] = pagination.next.to_s",["
|
24
|
-
::ScoutApm::AutoInstrument("collection",["
|
24
|
+
::ScoutApm::AutoInstrument("headers[PAGINATION_TOTAL_HEADER] = pagination.count.to_s",["ROOT/test/unit/auto_instrument/assignments.rb:24:in `paginate_collection'"]){headers[PAGINATION_TOTAL_HEADER] = pagination.count.to_s}
|
25
|
+
::ScoutApm::AutoInstrument("headers[PAGINATION_TOTAL_PAGES_HEADER] = pagination.pages.to_s",["ROOT/test/unit/auto_instrument/assignments.rb:25:in `paginate_collection'"]){headers[PAGINATION_TOTAL_PAGES_HEADER] = pagination.pages.to_s}
|
26
|
+
::ScoutApm::AutoInstrument("headers[PAGINATION_PER_PAGE_HEADER] = per_page.to_s",["ROOT/test/unit/auto_instrument/assignments.rb:26:in `paginate_collection'"]){headers[PAGINATION_PER_PAGE_HEADER] = per_page.to_s}
|
27
|
+
::ScoutApm::AutoInstrument("headers[PAGINATION_PAGE_HEADER] = pagination.page.to_s",["ROOT/test/unit/auto_instrument/assignments.rb:27:in `paginate_collection'"]){headers[PAGINATION_PAGE_HEADER] = pagination.page.to_s}
|
28
|
+
::ScoutApm::AutoInstrument("headers[PAGINATION_NEXT_PAGE_HEADER] = pagination.next.to_s",["ROOT/test/unit/auto_instrument/assignments.rb:28:in `paginate_collection'"]){headers[PAGINATION_NEXT_PAGE_HEADER] = pagination.next.to_s}
|
29
|
+
::ScoutApm::AutoInstrument("collection",["ROOT/test/unit/auto_instrument/assignments.rb:29:in `paginate_collection'"]){collection}
|
25
30
|
end
|
26
31
|
end
|
@@ -3,47 +3,47 @@ class ClientsController < ApplicationController
|
|
3
3
|
before_action :check_authorization
|
4
4
|
|
5
5
|
def index
|
6
|
-
if ::ScoutApm::AutoInstrument("params[:status] == \"activated\"",["
|
7
|
-
@clients = ::ScoutApm::AutoInstrument("Client.activated",["
|
6
|
+
if ::ScoutApm::AutoInstrument("params[:status] == \"activated\"",["ROOT/test/unit/auto_instrument/controller.rb:6:in `index'"]){params[:status] == "activated"}
|
7
|
+
@clients = ::ScoutApm::AutoInstrument("Client.activated",["ROOT/test/unit/auto_instrument/controller.rb:7:in `index'"]){Client.activated}
|
8
8
|
else
|
9
|
-
@clients = ::ScoutApm::AutoInstrument("Client.inactivated",["
|
9
|
+
@clients = ::ScoutApm::AutoInstrument("Client.inactivated",["ROOT/test/unit/auto_instrument/controller.rb:9:in `index'"]){Client.inactivated}
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def create
|
14
|
-
@client = ::ScoutApm::AutoInstrument("Client.new(params[:client])",["
|
15
|
-
if ::ScoutApm::AutoInstrument("@client.save",["
|
16
|
-
::ScoutApm::AutoInstrument("redirect_to @client",["
|
14
|
+
@client = ::ScoutApm::AutoInstrument("Client.new(params[:client])",["ROOT/test/unit/auto_instrument/controller.rb:14:in `create'"]){Client.new(params[:client])}
|
15
|
+
if ::ScoutApm::AutoInstrument("@client.save",["ROOT/test/unit/auto_instrument/controller.rb:15:in `create'"]){@client.save}
|
16
|
+
::ScoutApm::AutoInstrument("redirect_to @client",["ROOT/test/unit/auto_instrument/controller.rb:16:in `create'"]){redirect_to @client}
|
17
17
|
else
|
18
18
|
# This line overrides the default rendering behavior, which
|
19
19
|
# would have been to render the "create" view.
|
20
|
-
::ScoutApm::AutoInstrument("render \"new\"",["
|
20
|
+
::ScoutApm::AutoInstrument("render \"new\"",["ROOT/test/unit/auto_instrument/controller.rb:20:in `create'"]){render "new"}
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def edit
|
25
|
-
@client = ::ScoutApm::AutoInstrument("Client.new(params[:client])",["
|
25
|
+
@client = ::ScoutApm::AutoInstrument("Client.new(params[:client])",["ROOT/test/unit/auto_instrument/controller.rb:25:in `edit'"]){Client.new(params[:client])}
|
26
26
|
|
27
|
-
if ::ScoutApm::AutoInstrument("request.post?",["
|
28
|
-
::ScoutApm::AutoInstrument("@client.transaction do...",["
|
27
|
+
if ::ScoutApm::AutoInstrument("request.post?",["ROOT/test/unit/auto_instrument/controller.rb:27:in `edit'"]){request.post?}
|
28
|
+
::ScoutApm::AutoInstrument("@client.transaction do...",["ROOT/test/unit/auto_instrument/controller.rb:28:in `edit'"]){@client.transaction do
|
29
29
|
@client.update_attributes(params[:client])
|
30
30
|
end}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def data
|
35
|
-
@clients = ::ScoutApm::AutoInstrument("Client.all",["
|
35
|
+
@clients = ::ScoutApm::AutoInstrument("Client.all",["ROOT/test/unit/auto_instrument/controller.rb:35:in `data'"]){Client.all}
|
36
36
|
|
37
|
-
formatter = ::ScoutApm::AutoInstrument("proc do |row|...",["
|
37
|
+
formatter = ::ScoutApm::AutoInstrument("proc do |row|...",["ROOT/test/unit/auto_instrument/controller.rb:37:in `data'"]){proc do |row|
|
38
38
|
row.to_json
|
39
39
|
end}
|
40
40
|
|
41
|
-
::ScoutApm::AutoInstrument("respond_with @clients.each(&formatter).join(\"\\n\"), :content_type => '
|
41
|
+
::ScoutApm::AutoInstrument("respond_with @clients.each(&formatter).join(\"\\n\"), :content_type => 'application/json; boundary=NL'",["ROOT/test/unit/auto_instrument/controller.rb:41:in `data'"]){respond_with @clients.each(&formatter).join("\n"), :content_type => 'application/json; boundary=NL'}
|
42
42
|
end
|
43
43
|
|
44
44
|
def things
|
45
45
|
x = {}
|
46
46
|
x[:this] ||= 'foo'
|
47
|
-
x[:that] &&= ::ScoutApm::AutoInstrument("'
|
47
|
+
x[:that] &&= ::ScoutApm::AutoInstrument("'foo'.size",["ROOT/test/unit/auto_instrument/controller.rb:47:in `things'"]){'foo'.size}
|
48
48
|
end
|
49
49
|
end
|
@@ -3,6 +3,8 @@ require 'test_helper'
|
|
3
3
|
require 'scout_apm/auto_instrument'
|
4
4
|
|
5
5
|
class AutoInstrumentTest < Minitest::Test
|
6
|
+
ROOT = File.expand_path("../../", __dir__)
|
7
|
+
|
6
8
|
def source_path(name)
|
7
9
|
File.expand_path("auto_instrument/#{name}.rb", __dir__)
|
8
10
|
end
|
@@ -19,9 +21,7 @@ class AutoInstrumentTest < Minitest::Test
|
|
19
21
|
# test controller.rb file, which will be different on different environments.
|
20
22
|
# This normalizes backtraces across environments.
|
21
23
|
def normalize_backtrace(string)
|
22
|
-
string
|
23
|
-
.gsub(/\[".+auto_instrument\/.+?:.+?"\]/,'["BACKTRACE"]')
|
24
|
-
.gsub(/'.+auto_instrument\/.+'/,"'FILE_NAME'")
|
24
|
+
string.gsub(ROOT, "ROOT")
|
25
25
|
end
|
26
26
|
|
27
27
|
# Use this to automatically update the test fixtures.
|
@@ -33,18 +33,21 @@ class AutoInstrumentTest < Minitest::Test
|
|
33
33
|
|
34
34
|
def test_controller_rewrite
|
35
35
|
# update_instrumented_source("controller")
|
36
|
+
|
36
37
|
assert_equal instrumented_source("controller"),
|
37
38
|
normalize_backtrace(::ScoutApm::AutoInstrument::Rails.rewrite(source_path("controller")))
|
38
39
|
end
|
39
40
|
|
40
41
|
def test_rescue_from_rewrite
|
41
42
|
# update_instrumented_source("rescue_from")
|
43
|
+
|
42
44
|
assert_equal instrumented_source("rescue_from"),
|
43
45
|
normalize_backtrace(::ScoutApm::AutoInstrument::Rails.rewrite(source_path("rescue_from")))
|
44
46
|
end
|
45
47
|
|
46
48
|
def test_assignments_rewrite
|
47
49
|
# update_instrumented_source("assignments")
|
50
|
+
|
48
51
|
assert_equal instrumented_source("assignments"),
|
49
52
|
normalize_backtrace(::ScoutApm::AutoInstrument::Rails.rewrite(source_path("assignments")))
|
50
53
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'scout_apm/request_histograms'
|
4
|
+
|
5
|
+
class RequestHistogramsTest < Minitest::Test
|
6
|
+
def test_as_json_without_activesupport
|
7
|
+
rh = ScoutApm::RequestHistograms.new
|
8
|
+
|
9
|
+
rh.add("foo", 1)
|
10
|
+
rh.add("foo", 2)
|
11
|
+
rh.add("bar", 3)
|
12
|
+
|
13
|
+
j = rh.as_json
|
14
|
+
assert_equal 2, j.size
|
15
|
+
assert_equal ["bar", "foo"], j.keys.sort
|
16
|
+
end
|
17
|
+
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: 2.6.
|
4
|
+
version: 2.6.2
|
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: 2019-
|
12
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -423,6 +423,7 @@ files:
|
|
423
423
|
- test/unit/remote/test_message.rb
|
424
424
|
- test/unit/remote/test_router.rb
|
425
425
|
- test/unit/remote/test_server.rb
|
426
|
+
- test/unit/request_histograms_test.rb
|
426
427
|
- test/unit/scored_item_set_test.rb
|
427
428
|
- test/unit/serializers/payload_serializer_test.rb
|
428
429
|
- test/unit/slow_job_policy_test.rb
|
@@ -457,7 +458,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
457
458
|
- !ruby/object:Gem::Version
|
458
459
|
version: '0'
|
459
460
|
requirements: []
|
460
|
-
rubygems_version: 3.0.
|
461
|
+
rubygems_version: 3.0.4
|
461
462
|
signing_key:
|
462
463
|
specification_version: 4
|
463
464
|
summary: Ruby application performance monitoring
|
@@ -500,6 +501,7 @@ test_files:
|
|
500
501
|
- test/unit/remote/test_message.rb
|
501
502
|
- test/unit/remote/test_router.rb
|
502
503
|
- test/unit/remote/test_server.rb
|
504
|
+
- test/unit/request_histograms_test.rb
|
503
505
|
- test/unit/scored_item_set_test.rb
|
504
506
|
- test/unit/serializers/payload_serializer_test.rb
|
505
507
|
- test/unit/slow_job_policy_test.rb
|