scout_apm 1.6.8 → 2.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -1
- data/CHANGELOG.markdown +7 -57
- data/ext/allocations/allocations.c +84 -0
- data/ext/allocations/extconf.rb +3 -0
- data/lib/scout_apm/agent/reporting.rb +9 -32
- data/lib/scout_apm/agent.rb +45 -31
- data/lib/scout_apm/app_server_load.rb +1 -2
- data/lib/scout_apm/attribute_arranger.rb +0 -4
- data/lib/scout_apm/background_worker.rb +6 -9
- data/lib/scout_apm/bucket_name_splitter.rb +3 -3
- data/lib/scout_apm/call_set.rb +1 -0
- data/lib/scout_apm/config.rb +110 -66
- data/lib/scout_apm/environment.rb +16 -10
- data/lib/scout_apm/framework_integrations/rails_2.rb +12 -14
- data/lib/scout_apm/framework_integrations/rails_3_or_4.rb +5 -17
- data/lib/scout_apm/framework_integrations/ruby.rb +0 -4
- data/lib/scout_apm/framework_integrations/sinatra.rb +0 -4
- data/lib/scout_apm/histogram.rb +0 -20
- data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +1 -4
- data/lib/scout_apm/instruments/active_record.rb +149 -8
- data/lib/scout_apm/instruments/mongoid.rb +5 -78
- data/lib/scout_apm/instruments/process/process_cpu.rb +0 -12
- data/lib/scout_apm/instruments/process/process_memory.rb +14 -43
- data/lib/scout_apm/layaway.rb +34 -134
- data/lib/scout_apm/layaway_file.rb +50 -27
- data/lib/scout_apm/layer.rb +45 -1
- data/lib/scout_apm/layer_converters/allocation_metric_converter.rb +17 -0
- data/lib/scout_apm/layer_converters/converter_base.rb +4 -6
- data/lib/scout_apm/layer_converters/job_converter.rb +1 -0
- data/lib/scout_apm/layer_converters/metric_converter.rb +2 -1
- data/lib/scout_apm/layer_converters/slow_job_converter.rb +42 -21
- data/lib/scout_apm/layer_converters/slow_request_converter.rb +58 -37
- data/lib/scout_apm/metric_meta.rb +1 -5
- data/lib/scout_apm/metric_set.rb +6 -15
- data/lib/scout_apm/reporter.rb +4 -6
- data/lib/scout_apm/serializers/metrics_to_json_serializer.rb +5 -1
- data/lib/scout_apm/serializers/payload_serializer_to_json.rb +1 -3
- data/lib/scout_apm/serializers/slow_jobs_serializer_to_json.rb +5 -3
- data/lib/scout_apm/slow_job_policy.rb +19 -89
- data/lib/scout_apm/slow_job_record.rb +12 -20
- data/lib/scout_apm/slow_request_policy.rb +12 -80
- data/lib/scout_apm/slow_transaction.rb +16 -20
- data/lib/scout_apm/stackprof_tree_collapser.rb +103 -0
- data/lib/scout_apm/store.rb +16 -78
- data/lib/scout_apm/tracked_request.rb +53 -36
- data/lib/scout_apm/utils/active_record_metric_name.rb +2 -0
- data/lib/scout_apm/utils/fake_stack_prof.rb +40 -0
- data/lib/scout_apm/utils/klass_helper.rb +26 -0
- data/lib/scout_apm/utils/sql_sanitizer.rb +1 -1
- data/lib/scout_apm/utils/sql_sanitizer_regex.rb +2 -2
- data/lib/scout_apm/utils/sql_sanitizer_regex_1_8_7.rb +2 -2
- data/lib/scout_apm/version.rb +1 -1
- data/lib/scout_apm.rb +13 -7
- data/scout_apm.gemspec +3 -1
- data/test/test_helper.rb +3 -4
- data/test/unit/layaway_test.rb +8 -5
- data/test/unit/serializers/payload_serializer_test.rb +2 -2
- data/test/unit/slow_item_set_test.rb +1 -2
- data/test/unit/sql_sanitizer_test.rb +0 -6
- metadata +28 -20
- data/LICENSE.md +0 -27
- data/lib/scout_apm/instruments/grape.rb +0 -69
- data/lib/scout_apm/instruments/percentile_sampler.rb +0 -37
- data/lib/scout_apm/request_histograms.rb +0 -46
- data/lib/scout_apm/scored_item_set.rb +0 -79
- data/test/unit/metric_set_test.rb +0 -101
- data/test/unit/scored_item_set_test.rb +0 -65
- data/test/unit/slow_request_policy_test.rb +0 -42
@@ -0,0 +1,26 @@
|
|
1
|
+
module ScoutApm
|
2
|
+
module Utils
|
3
|
+
module KlassHelper
|
4
|
+
# KlassHelper.defined?("ActiveRecord", "Base") #=> true / false
|
5
|
+
# KlassHelper.defined?("ActiveRecord::Base") #=> true / false
|
6
|
+
|
7
|
+
def self.defined?(*names)
|
8
|
+
if names.length == 1
|
9
|
+
names = names[0].split("::")
|
10
|
+
end
|
11
|
+
|
12
|
+
obj = Object
|
13
|
+
|
14
|
+
names.each do |name|
|
15
|
+
begin
|
16
|
+
obj = obj.const_get(name)
|
17
|
+
rescue NameError
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -75,7 +75,7 @@ module ScoutApm
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def scrubbed(str)
|
78
|
-
return '' if !str.is_a?(String) || str.length >
|
78
|
+
return '' if !str.is_a?(String) || str.length > 1000 # safeguard - don't sanitize or scrub large SQL statements
|
79
79
|
return str if !str.respond_to?(:encode) # Ruby <= 1.8 doesn't have string encoding
|
80
80
|
return str if str.valid_encoding? # Whatever encoding it is, it is valid and we can operate on it
|
81
81
|
ScoutApm::Agent.instance.logger.debug "Scrubbing invalid sql encoding."
|
@@ -13,8 +13,8 @@ module ScoutApm
|
|
13
13
|
|
14
14
|
MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
15
15
|
MYSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
16
|
-
MYSQL_REMOVE_SINGLE_QUOTE_STRINGS =
|
17
|
-
MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS =
|
16
|
+
MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = /'(?:[^']|'')*'/.freeze
|
17
|
+
MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = /"(?:[^"]|"")*"/.freeze
|
18
18
|
MYSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
19
19
|
|
20
20
|
SQLITE_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
@@ -13,8 +13,8 @@ module ScoutApm
|
|
13
13
|
|
14
14
|
MYSQL_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
15
15
|
MYSQL_REMOVE_INTEGERS = /\b\d+\b/.freeze
|
16
|
-
MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = /'(
|
17
|
-
MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = /"(
|
16
|
+
MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = /'(?:[^']|'')*'/.freeze
|
17
|
+
MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = /"(?:[^"]|"")*"/.freeze
|
18
18
|
MYSQL_IN_CLAUSE = /IN\s+\(\?[^\)]*\)/.freeze
|
19
19
|
|
20
20
|
SQLITE_VAR_INTERPOLATION = %r|\[\[.*\]\]\s*$|.freeze
|
data/lib/scout_apm/version.rb
CHANGED
data/lib/scout_apm.rb
CHANGED
@@ -18,6 +18,12 @@ require 'yaml'
|
|
18
18
|
#####################################
|
19
19
|
# Gem Requires
|
20
20
|
#####################################
|
21
|
+
begin
|
22
|
+
require 'stackprof'
|
23
|
+
rescue LoadError
|
24
|
+
require 'scout_apm/utils/fake_stack_prof'
|
25
|
+
end
|
26
|
+
require 'rusage'
|
21
27
|
|
22
28
|
#####################################
|
23
29
|
# Internal Requires
|
@@ -37,6 +43,7 @@ require 'scout_apm/layer_converters/slow_job_converter'
|
|
37
43
|
require 'scout_apm/layer_converters/metric_converter'
|
38
44
|
require 'scout_apm/layer_converters/slow_request_converter'
|
39
45
|
require 'scout_apm/layer_converters/request_queue_time_converter'
|
46
|
+
require 'scout_apm/layer_converters/allocation_metric_converter'
|
40
47
|
|
41
48
|
require 'scout_apm/server_integrations/passenger'
|
42
49
|
require 'scout_apm/server_integrations/puma'
|
@@ -77,19 +84,19 @@ require 'scout_apm/instruments/action_controller_rails_3_rails4'
|
|
77
84
|
require 'scout_apm/instruments/middleware_summary'
|
78
85
|
# require 'scout_apm/instruments/middleware_detailed' # Currently disabled functionality, see the file for details.
|
79
86
|
require 'scout_apm/instruments/rails_router'
|
80
|
-
require 'scout_apm/instruments/grape'
|
81
87
|
require 'scout_apm/instruments/sinatra'
|
82
88
|
require 'scout_apm/instruments/process/process_cpu'
|
83
89
|
require 'scout_apm/instruments/process/process_memory'
|
84
|
-
require '
|
90
|
+
require 'allocations'
|
85
91
|
|
86
92
|
require 'scout_apm/app_server_load'
|
87
93
|
|
88
|
-
require 'scout_apm/utils/sql_sanitizer'
|
89
|
-
require 'scout_apm/utils/backtrace_parser'
|
90
94
|
require 'scout_apm/utils/active_record_metric_name'
|
91
|
-
require 'scout_apm/utils/
|
95
|
+
require 'scout_apm/utils/backtrace_parser'
|
92
96
|
require 'scout_apm/utils/installed_gems'
|
97
|
+
require 'scout_apm/utils/klass_helper'
|
98
|
+
require 'scout_apm/utils/null_logger'
|
99
|
+
require 'scout_apm/utils/sql_sanitizer'
|
93
100
|
require 'scout_apm/utils/time'
|
94
101
|
require 'scout_apm/utils/unique_id'
|
95
102
|
|
@@ -108,17 +115,16 @@ require 'scout_apm/metric_set'
|
|
108
115
|
require 'scout_apm/store'
|
109
116
|
require 'scout_apm/tracer'
|
110
117
|
require 'scout_apm/context'
|
118
|
+
require 'scout_apm/stackprof_tree_collapser'
|
111
119
|
|
112
120
|
require 'scout_apm/metric_meta'
|
113
121
|
require 'scout_apm/metric_stats'
|
114
122
|
require 'scout_apm/slow_transaction'
|
115
123
|
require 'scout_apm/slow_job_record'
|
116
124
|
require 'scout_apm/slow_item_set'
|
117
|
-
require 'scout_apm/scored_item_set'
|
118
125
|
require 'scout_apm/slow_request_policy'
|
119
126
|
require 'scout_apm/slow_job_policy'
|
120
127
|
require 'scout_apm/job_record'
|
121
|
-
require 'scout_apm/request_histograms'
|
122
128
|
|
123
129
|
require 'scout_apm/capacity'
|
124
130
|
require 'scout_apm/attribute_arranger'
|
data/scout_apm.gemspec
CHANGED
@@ -10,7 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://github.com/scoutapp/scout_apm_ruby"
|
11
11
|
s.summary = "Ruby application performance monitoring"
|
12
12
|
s.description = "Monitors Ruby apps and reports detailed metrics on performance to Scout."
|
13
|
-
s.license = "Proprietary (See LICENSE.md)"
|
14
13
|
|
15
14
|
s.rubyforge_project = "scout_apm"
|
16
15
|
|
@@ -18,6 +17,9 @@ Gem::Specification.new do |s|
|
|
18
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
19
|
s.require_paths = ["lib","data"]
|
20
|
+
s.extensions << 'ext/allocations/extconf.rb'
|
21
|
+
|
22
|
+
s.add_runtime_dependency "rusage", '~> 0.2.0'
|
21
23
|
|
22
24
|
s.add_development_dependency "minitest"
|
23
25
|
s.add_development_dependency "pry"
|
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
# Load & Start simplecov before loading scout_apm
|
2
|
-
require 'simplecov'
|
3
|
-
SimpleCov.start
|
4
|
-
|
5
1
|
require 'minitest/autorun'
|
6
2
|
require 'minitest/unit'
|
7
3
|
require 'minitest/pride'
|
8
4
|
require 'pry'
|
9
5
|
|
6
|
+
# Load & Start simplecov before loading scout_apm
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
10
9
|
|
11
10
|
require 'scout_apm'
|
12
11
|
|
data/test/unit/layaway_test.rb
CHANGED
@@ -18,12 +18,15 @@ class LayawayTest < Minitest::Test
|
|
18
18
|
|
19
19
|
def test_merge_reporting_period
|
20
20
|
File.open(DATA_FILE_PATH, 'w') { |file| file.write(Marshal.dump(NEW_FORMAT)) }
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
ScoutApm::Agent.instance.start
|
22
|
+
|
23
|
+
data = ScoutApm::Layaway.new
|
24
|
+
t = ScoutApm::StoreReportingPeriodTimestamp.new
|
25
|
+
data.add_reporting_period(TIMESTAMP,ScoutApm::StoreReportingPeriod.new(TIMESTAMP))
|
26
|
+
assert_equal [TIMESTAMP], Marshal.load(File.read(DATA_FILE_PATH)).keys
|
27
|
+
# TODO - add tests to verify metrics+slow transactions are merged
|
25
28
|
end
|
26
29
|
|
27
30
|
TIMESTAMP = ScoutApm::StoreReportingPeriodTimestamp.new(Time.parse("2015-01-01"))
|
28
31
|
NEW_FORMAT = {TIMESTAMP => ScoutApm::StoreReportingPeriod.new(TIMESTAMP)} # Format for 1.2+ agents
|
29
|
-
end
|
32
|
+
end
|
@@ -6,6 +6,7 @@ require 'scout_apm/serializers/payload_serializer_to_json'
|
|
6
6
|
require 'scout_apm/slow_transaction'
|
7
7
|
require 'scout_apm/metric_meta'
|
8
8
|
require 'scout_apm/metric_stats'
|
9
|
+
require 'scout_apm/stackprof_tree_collapser'
|
9
10
|
require 'scout_apm/utils/fake_stack_prof'
|
10
11
|
require 'scout_apm/context'
|
11
12
|
require 'ostruct'
|
@@ -144,7 +145,7 @@ class PayloadSerializerTest < Minitest::Test
|
|
144
145
|
context = ScoutApm::Context.new
|
145
146
|
context.add({"this" => "that"})
|
146
147
|
context.add_user({"hello" => "goodbye"})
|
147
|
-
slow_t = ScoutApm::SlowTransaction.new("http://example.com/blabla", "Buckethead/something/else", 1.23, slow_transaction_metrics, context, Time.at(1448198788), []
|
148
|
+
slow_t = ScoutApm::SlowTransaction.new("http://example.com/blabla", "Buckethead/something/else", 1.23, slow_transaction_metrics, context, Time.at(1448198788), [])
|
148
149
|
payload = ScoutApm::Serializers::PayloadSerializerToJson.serialize({}, {}, [slow_t], [], [])
|
149
150
|
formatted_slow_transactions = [
|
150
151
|
{
|
@@ -157,7 +158,6 @@ class PayloadSerializerTest < Minitest::Test
|
|
157
158
|
"uri" => "http://example.com/blabla",
|
158
159
|
"context" => {"this"=>"that", "user"=>{"hello"=>"goodbye"}},
|
159
160
|
"prof" => [],
|
160
|
-
"score" => 10,
|
161
161
|
"metrics" => [
|
162
162
|
{
|
163
163
|
"key" => {
|
@@ -85,12 +85,6 @@ module ScoutApm
|
|
85
85
|
assert_equal %q|SELECT `blogs`.* FROM `blogs` WHERE (title = ?)|, ss.to_s
|
86
86
|
end
|
87
87
|
|
88
|
-
def test_mysql_quotes
|
89
|
-
sql = %q|INSERT INTO `users` VALUES ('foo', 'b\'ar')|
|
90
|
-
ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :mysql }
|
91
|
-
assert_equal %q|INSERT INTO `users` VALUES (?, ?)|, ss.to_s
|
92
|
-
end
|
93
|
-
|
94
88
|
def test_scrubs_invalid_encoding
|
95
89
|
sql = "SELECT `blogs`.* FROM `blogs` WHERE (title = 'a\255c')".force_encoding('UTF-8')
|
96
90
|
assert_equal false, sql.valid_encoding?
|
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
|
+
version: 2.0.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Haynes
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rusage
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.2.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.2.0
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: minitest
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,16 +85,18 @@ description: Monitors Ruby apps and reports detailed metrics on performance to S
|
|
71
85
|
email:
|
72
86
|
- support@scoutapp.com
|
73
87
|
executables: []
|
74
|
-
extensions:
|
88
|
+
extensions:
|
89
|
+
- ext/allocations/extconf.rb
|
75
90
|
extra_rdoc_files: []
|
76
91
|
files:
|
77
92
|
- ".gitignore"
|
78
93
|
- CHANGELOG.markdown
|
79
94
|
- Gemfile
|
80
|
-
- LICENSE.md
|
81
95
|
- README.markdown
|
82
96
|
- Rakefile
|
83
97
|
- data/cacert.pem
|
98
|
+
- ext/allocations/allocations.c
|
99
|
+
- ext/allocations/extconf.rb
|
84
100
|
- lib/scout_apm.rb
|
85
101
|
- lib/scout_apm/agent.rb
|
86
102
|
- lib/scout_apm/agent/logging.rb
|
@@ -111,7 +127,6 @@ files:
|
|
111
127
|
- lib/scout_apm/instruments/active_record.rb
|
112
128
|
- lib/scout_apm/instruments/delayed_job.rb
|
113
129
|
- lib/scout_apm/instruments/elasticsearch.rb
|
114
|
-
- lib/scout_apm/instruments/grape.rb
|
115
130
|
- lib/scout_apm/instruments/http_client.rb
|
116
131
|
- lib/scout_apm/instruments/influxdb.rb
|
117
132
|
- lib/scout_apm/instruments/middleware_detailed.rb
|
@@ -119,7 +134,6 @@ files:
|
|
119
134
|
- lib/scout_apm/instruments/mongoid.rb
|
120
135
|
- lib/scout_apm/instruments/moped.rb
|
121
136
|
- lib/scout_apm/instruments/net_http.rb
|
122
|
-
- lib/scout_apm/instruments/percentile_sampler.rb
|
123
137
|
- lib/scout_apm/instruments/process/process_cpu.rb
|
124
138
|
- lib/scout_apm/instruments/process/process_memory.rb
|
125
139
|
- lib/scout_apm/instruments/rails_router.rb
|
@@ -129,6 +143,7 @@ files:
|
|
129
143
|
- lib/scout_apm/layaway.rb
|
130
144
|
- lib/scout_apm/layaway_file.rb
|
131
145
|
- lib/scout_apm/layer.rb
|
146
|
+
- lib/scout_apm/layer_converters/allocation_metric_converter.rb
|
132
147
|
- lib/scout_apm/layer_converters/converter_base.rb
|
133
148
|
- lib/scout_apm/layer_converters/depth_first_walker.rb
|
134
149
|
- lib/scout_apm/layer_converters/error_converter.rb
|
@@ -145,9 +160,7 @@ files:
|
|
145
160
|
- lib/scout_apm/platform_integrations/heroku.rb
|
146
161
|
- lib/scout_apm/platform_integrations/server.rb
|
147
162
|
- lib/scout_apm/reporter.rb
|
148
|
-
- lib/scout_apm/request_histograms.rb
|
149
163
|
- lib/scout_apm/request_manager.rb
|
150
|
-
- lib/scout_apm/scored_item_set.rb
|
151
164
|
- lib/scout_apm/serializers/app_server_load_serializer.rb
|
152
165
|
- lib/scout_apm/serializers/deploy_serializer.rb
|
153
166
|
- lib/scout_apm/serializers/directive_serializer.rb
|
@@ -169,12 +182,15 @@ files:
|
|
169
182
|
- lib/scout_apm/slow_request_policy.rb
|
170
183
|
- lib/scout_apm/slow_transaction.rb
|
171
184
|
- lib/scout_apm/stack_item.rb
|
185
|
+
- lib/scout_apm/stackprof_tree_collapser.rb
|
172
186
|
- lib/scout_apm/store.rb
|
173
187
|
- lib/scout_apm/tracer.rb
|
174
188
|
- lib/scout_apm/tracked_request.rb
|
175
189
|
- lib/scout_apm/utils/active_record_metric_name.rb
|
176
190
|
- lib/scout_apm/utils/backtrace_parser.rb
|
191
|
+
- lib/scout_apm/utils/fake_stack_prof.rb
|
177
192
|
- lib/scout_apm/utils/installed_gems.rb
|
193
|
+
- lib/scout_apm/utils/klass_helper.rb
|
178
194
|
- lib/scout_apm/utils/null_logger.rb
|
179
195
|
- lib/scout_apm/utils/sql_sanitizer.rb
|
180
196
|
- lib/scout_apm/utils/sql_sanitizer_regex.rb
|
@@ -191,17 +207,13 @@ files:
|
|
191
207
|
- test/unit/histogram_test.rb
|
192
208
|
- test/unit/instruments/active_record_instruments_test.rb
|
193
209
|
- test/unit/layaway_test.rb
|
194
|
-
- test/unit/metric_set_test.rb
|
195
|
-
- test/unit/scored_item_set_test.rb
|
196
210
|
- test/unit/serializers/payload_serializer_test.rb
|
197
211
|
- test/unit/slow_item_set_test.rb
|
198
212
|
- test/unit/slow_job_policy_test.rb
|
199
|
-
- test/unit/slow_request_policy_test.rb
|
200
213
|
- test/unit/sql_sanitizer_test.rb
|
201
214
|
- test/unit/utils/active_record_metric_name_test.rb
|
202
215
|
homepage: https://github.com/scoutapp/scout_apm_ruby
|
203
|
-
licenses:
|
204
|
-
- Proprietary (See LICENSE.md)
|
216
|
+
licenses: []
|
205
217
|
metadata: {}
|
206
218
|
post_install_message:
|
207
219
|
rdoc_options: []
|
@@ -215,12 +227,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
227
|
version: '0'
|
216
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
229
|
requirements:
|
218
|
-
- - "
|
230
|
+
- - ">"
|
219
231
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
232
|
+
version: 1.3.1
|
221
233
|
requirements: []
|
222
234
|
rubyforge_project: scout_apm
|
223
|
-
rubygems_version: 2.6
|
235
|
+
rubygems_version: 2.4.6
|
224
236
|
signing_key:
|
225
237
|
specification_version: 4
|
226
238
|
summary: Ruby application performance monitoring
|
@@ -233,12 +245,8 @@ test_files:
|
|
233
245
|
- test/unit/histogram_test.rb
|
234
246
|
- test/unit/instruments/active_record_instruments_test.rb
|
235
247
|
- test/unit/layaway_test.rb
|
236
|
-
- test/unit/metric_set_test.rb
|
237
|
-
- test/unit/scored_item_set_test.rb
|
238
248
|
- test/unit/serializers/payload_serializer_test.rb
|
239
249
|
- test/unit/slow_item_set_test.rb
|
240
250
|
- test/unit/slow_job_policy_test.rb
|
241
|
-
- test/unit/slow_request_policy_test.rb
|
242
251
|
- test/unit/sql_sanitizer_test.rb
|
243
252
|
- test/unit/utils/active_record_metric_name_test.rb
|
244
|
-
has_rdoc:
|
data/LICENSE.md
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# Scout Software Agent License
|
2
|
-
|
3
|
-
Subject to and conditioned upon your continued compliance with the terms and conditions of this license, Zimuth, Inc. grants you a non-exclusive, non-sublicensable and non-transferable, limited license to install, use and run one copy of this software on each of your and your affiliate’s computers. This license also grants you the limited right to distribute verbatim copies of this software and documentation to third parties provided the software and documentation will (a) remain the exclusive property of Zimuth; (b) be subject to the terms and conditions of this license; and (c) include a complete and unaltered copy of this license and all other copyright or other intellectual property rights notices contained in the original.
|
4
|
-
|
5
|
-
The software includes the open-source components listed below. Any use of the open-source components by you shall be governed by, and subject to, the terms and conditions of the applicable open-source licenses.
|
6
|
-
|
7
|
-
Except as this license expressly permits, you may not:
|
8
|
-
|
9
|
-
* copy the software, in whole or in part;
|
10
|
-
* modify, correct, adapt, translate, enhance or otherwise prepare derivative works or improvements of the software;
|
11
|
-
* sell, sublicense, assign, distribute, publish, transfer or otherwise make available the software to any person or entity;
|
12
|
-
* remove, delete, efface, alter, obscure, translate, combine, supplement or otherwise change any trademarks, terms of the documentation, warranties, disclaimers, or intellectual property rights, or other symbols, notices, marks or serial numbers on or relating to any copy of the software or documentation; or
|
13
|
-
use the software in any manner or for any purpose that infringes, misappropriates or otherwise violates any intellectual property right or other right of any person or entity, or that violates any applicable law;
|
14
|
-
|
15
|
-
By using the software, you acknowledge and agree that:
|
16
|
-
|
17
|
-
* the software and documentation are licensed, not sold, to you by Zimuth and you do not and will not have or acquire under or in connection with this license any ownership interest in the software or documentation, or in any related intellectual property rights; and
|
18
|
-
* Zimuth will remain the sole and exclusive owner of all right, title and interest in and to the software and documentation, including all related intellectual property rights, subject only to the rights of third parties in open-source components and the limited license granted to you under this license; and
|
19
|
-
|
20
|
-
Except for the limited rights and licenses expressly granted to you under this agreement, nothing in this license grants, by implication, waiver, estoppel or otherwise, to you or any third party any intellectual property rights or other right, title, or interest in or to any of the software or documentation.
|
21
|
-
|
22
|
-
This license shall be automatically terminated and revoked if you exceed the scope or violate any terms and conditions of this license.
|
23
|
-
|
24
|
-
ALL LICENSED SOFTWARE, DOCUMENTATION AND OTHER PRODUCTS, INFORMATION, MATERIALS AND SERVICES PROVIDED BY ZIMUTH ARE PROVIDED HERE “AS IS.” ZIMUTH DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, STATUTORY OR OTHER (INCLUDING ALL WARRANTIES ARISING FROM COURSE OF DEALING, USAGE OR TRADE PRACTICE), AND SPECIFICALLY DISCLAIMS ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. WITHOUT LIMITING THE FOREGOING, ZIMUTH MAKES NO WARRANTY OF ANY KIND THAT THE LICENSED SOFTWARE OR DOCUMENTATION, OR ANY OTHER LICENSOR OR THIRD-PARTY GOODS, SERVICES, TECHNOLOGIES OR MATERIALS, WILL MEET YOUR REQUIREMENTS, OPERATE WITHOUT INTERRUPTION, ACHIEVE ANY INTENDED RESULT, BE COMPATIBLE OR WORK WITH ANY OTHER GOODS, SERVICES, TECHNOLOGIES OR MATERIALS (INCLUDING ANY SOFTWARE, HARDWARE, SYSTEM OR NETWORK) EXCEPT IF AND TO THE EXTENT EXPRESSLY SET FORTH IN THE DOCUMENTATION, OR BE SECURE, ACCURATE, COMPLETE, FREE OF HARMFUL CODE OR ERROR FREE. ALL OPEN-SOURCE COMPONENTS AND OTHER THIRD-PARTY MATERIALS ARE PROVIDED “AS IS” AND ANY REPRESENTATION OR WARRANTY OF OR CONCERNING ANY OF THEM IS STRICTLY BETWEEN LICENSEE AND THE THIRD-PARTY OWNER OR DISTRIBUTOR OF SUCH OPEN-SOURCE COMPONENTS AND THIRD-PARTY MATERIALS.
|
25
|
-
|
26
|
-
IN NO EVENT WILL ZIMUTH BE LIABLE UNDER OR IN CONNECTION WITH THIS LICENSE OR ITS SUBJECT MATTER UNDER ANY LEGAL OR EQUITABLE THEORY, INCLUDING BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY AND OTHERWISE, FOR ANY CONSEQUENTIAL, INCIDENTAL, INDIRECT, EXEMPLARY, SPECIAL, ENHANCED OR PUNITIVE DAMAGES, IN EACH CASE REGARDLESS OF WHETHER SUCH PERSONS WERE ADVISED OF THE POSSIBILITY OF SUCH LOSSES OR DAMAGES OR SUCH LOSSES OR DAMAGES WERE OTHERWISE FORESEEABLE, AND NOTWITHSTANDING THE FAILURE OF ANY AGREED OR OTHER REMEDY OF ITS ESSENTIAL PURPOSE.
|
27
|
-
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module ScoutApm
|
2
|
-
module Instruments
|
3
|
-
class Grape
|
4
|
-
attr_reader :logger
|
5
|
-
|
6
|
-
def initalize(logger=ScoutApm::Agent.instance.logger)
|
7
|
-
@logger = logger
|
8
|
-
@installed = false
|
9
|
-
end
|
10
|
-
|
11
|
-
def installed?
|
12
|
-
@installed
|
13
|
-
end
|
14
|
-
|
15
|
-
def install
|
16
|
-
@installed = true
|
17
|
-
|
18
|
-
if defined?(::Grape) && defined?(::Grape::Endpoint)
|
19
|
-
ScoutApm::Agent.instance.logger.info "Instrumenting Grape::Endpoint"
|
20
|
-
|
21
|
-
::Grape::Endpoint.class_eval do
|
22
|
-
include ScoutApm::Instruments::GrapeEndpointInstruments
|
23
|
-
|
24
|
-
alias run_without_scout_instruments run
|
25
|
-
alias run run_with_scout_instruments
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module GrapeEndpointInstruments
|
32
|
-
def run_with_scout_instruments
|
33
|
-
request = ::Grape::Request.new(env)
|
34
|
-
req = ScoutApm::RequestManager.lookup
|
35
|
-
path = ScoutApm::Agent.instance.config.value("uri_reporting") == 'path' ? request.path : request.fullpath
|
36
|
-
req.annotate_request(:uri => path)
|
37
|
-
|
38
|
-
# IP Spoofing Protection can throw an exception, just move on w/o remote ip
|
39
|
-
req.context.add_user(:ip => request.ip) rescue nil
|
40
|
-
|
41
|
-
req.set_headers(request.headers)
|
42
|
-
req.web!
|
43
|
-
|
44
|
-
begin
|
45
|
-
name = ["Grape",
|
46
|
-
self.options[:method].first,
|
47
|
-
self.options[:for].to_s,
|
48
|
-
self.namespace.sub(%r{\A/}, ''), # removing leading slashes
|
49
|
-
self.options[:path].first,
|
50
|
-
].compact.map{ |n| n.to_s }.join("/")
|
51
|
-
rescue => e
|
52
|
-
ScoutApm::Agent.instance.logger.info("Error getting Grape Endpoint Name. Error: #{e.message}. Options: #{self.options.inspect}")
|
53
|
-
name = "Grape/Unknown"
|
54
|
-
end
|
55
|
-
|
56
|
-
req.start_layer( ScoutApm::Layer.new("Controller", name) )
|
57
|
-
begin
|
58
|
-
run_without_scout_instruments
|
59
|
-
rescue
|
60
|
-
req.error!
|
61
|
-
raise
|
62
|
-
ensure
|
63
|
-
req.stop_layer
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module ScoutApm
|
2
|
-
module Instruments
|
3
|
-
class PercentileSampler
|
4
|
-
attr_reader :logger
|
5
|
-
|
6
|
-
attr_reader :percentiles
|
7
|
-
|
8
|
-
def initialize(logger, percentiles)
|
9
|
-
@logger = logger
|
10
|
-
@percentiles = Array(percentiles)
|
11
|
-
end
|
12
|
-
|
13
|
-
def human_name
|
14
|
-
"Percentiles"
|
15
|
-
end
|
16
|
-
|
17
|
-
# Gets the 95th%ile for the time requested
|
18
|
-
def metrics(time)
|
19
|
-
ms = {}
|
20
|
-
histos = ScoutApm::Agent.instance.request_histograms_by_time[time]
|
21
|
-
histos.each_name do |name|
|
22
|
-
percentiles.each do |percentile|
|
23
|
-
meta = MetricMeta.new("Percentile/#{percentile}/#{name}")
|
24
|
-
stat = MetricStats.new
|
25
|
-
stat.update!(histos.quantile(name, percentile))
|
26
|
-
ms[meta] = stat
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Wipe the histograms we just collected data on
|
31
|
-
ScoutApm::Agent.instance.request_histograms_by_time.delete(time)
|
32
|
-
|
33
|
-
ms
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module ScoutApm
|
2
|
-
class RequestHistograms
|
3
|
-
DEFAULT_HISTOGRAM_SIZE = 50
|
4
|
-
|
5
|
-
# Private Accessor:
|
6
|
-
# A hash of Endpoint Name to an approximate histogram
|
7
|
-
#
|
8
|
-
# Each time a new request is requested to see if it's slow or not, we
|
9
|
-
# should insert it into the histogram, and get the approximate percentile
|
10
|
-
# of that time
|
11
|
-
attr_reader :histograms
|
12
|
-
private :histograms
|
13
|
-
|
14
|
-
attr_reader :histogram_size
|
15
|
-
|
16
|
-
def initialize(histogram_size = DEFAULT_HISTOGRAM_SIZE)
|
17
|
-
@histogram_size = histogram_size
|
18
|
-
initialize_histograms_hash
|
19
|
-
end
|
20
|
-
|
21
|
-
def each_name
|
22
|
-
@histograms.keys.each { |n| yield n }
|
23
|
-
end
|
24
|
-
|
25
|
-
def add(item, value)
|
26
|
-
@histograms[item].add(value)
|
27
|
-
end
|
28
|
-
|
29
|
-
def approximate_quantile_of_value(item, value)
|
30
|
-
@histograms[item].approximate_quantile_of_value(value)
|
31
|
-
end
|
32
|
-
|
33
|
-
def quantile(item, q)
|
34
|
-
@histograms[item].quantile(q)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Wipes all histograms, setting them back to empty
|
38
|
-
def reset_all!
|
39
|
-
initialize_histograms_hash
|
40
|
-
end
|
41
|
-
|
42
|
-
def initialize_histograms_hash
|
43
|
-
@histograms = Hash.new { |h, k| h[k] = NumericHistogram.new(histogram_size) }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# Attempts to keep the highest score.
|
2
|
-
#
|
3
|
-
# Each item must respond to:
|
4
|
-
# #call to get the storable item
|
5
|
-
# #name to get a unique identifier of the storable
|
6
|
-
# #score to get a numeric score, where higher is better
|
7
|
-
module ScoutApm
|
8
|
-
class ScoredItemSet
|
9
|
-
include Enumerable
|
10
|
-
|
11
|
-
# A number larger than any score we will actually get.
|
12
|
-
ARBITRARILY_LARGE = 100000000
|
13
|
-
|
14
|
-
# Without otherwise saying, default the size to this
|
15
|
-
DEFAULT_MAX_SIZE = 10
|
16
|
-
|
17
|
-
attr_reader :max_size
|
18
|
-
attr_reader :items
|
19
|
-
|
20
|
-
def initialize(max_size = DEFAULT_MAX_SIZE)
|
21
|
-
@items = {}
|
22
|
-
@max_size = max_size
|
23
|
-
end
|
24
|
-
|
25
|
-
def each
|
26
|
-
items.each do |(_, (_, item))|
|
27
|
-
yield item
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# This function is a large if statement, with a few branches. See inline comments for each branch.
|
32
|
-
def <<(new_item)
|
33
|
-
return if new_item.name == :unknown
|
34
|
-
|
35
|
-
# If we have this item in the hash already, compare the new & old ones, and store
|
36
|
-
# the new one only if it's higher score.
|
37
|
-
if items.has_key?(new_item.name)
|
38
|
-
if new_item.score > items[new_item.name].first
|
39
|
-
store!(new_item)
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
# If the set is full, then we have to see if we evict anything to store
|
44
|
-
# this one
|
45
|
-
elsif full?
|
46
|
-
smallest_name, smallest_score = items.inject([nil, ARBITRARILY_LARGE]) do |(memo_name, memo_score), (name, (stored_score, _))|
|
47
|
-
if stored_score < memo_score
|
48
|
-
[name, stored_score]
|
49
|
-
else
|
50
|
-
[memo_name, memo_score]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if smallest_score < new_item.score
|
55
|
-
items.delete(smallest_name)
|
56
|
-
store!(new_item)
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
# Set isn't full, and we've not seen this new_item, so go ahead and store it.
|
61
|
-
else
|
62
|
-
store!(new_item)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def full?
|
70
|
-
items.size >= max_size
|
71
|
-
end
|
72
|
-
|
73
|
-
def store!(new_item)
|
74
|
-
if !new_item.name.nil? # Never store a nil name.
|
75
|
-
items[new_item.name] = [new_item.score, new_item.call]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|