scout_apm 1.2.13 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +4 -0
- data/README.markdown +2 -2
- data/lib/scout_apm/agent/logging.rb +15 -3
- data/lib/scout_apm/instruments/active_record.rb +1 -1
- data/lib/scout_apm/layer_converter.rb +12 -12
- data/lib/scout_apm/slow_request_policy.rb +5 -3
- data/lib/scout_apm/store.rb +7 -18
- data/lib/scout_apm/tracer.rb +1 -1
- data/lib/scout_apm/utils/active_record_metric_name.rb +1 -1
- data/lib/scout_apm/version.rb +1 -1
- data/test/unit/utils/active_record_metric_name_test.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775fbb31b292af0249e53823fd743b051f12a612
|
4
|
+
data.tar.gz: c38270792896a7d986a4ef87171b7d532ca8d39d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f86a5da6ce114547d61fedb7b955233e43b65246064edf74ca4630affdf872a709946f8dff9aef5c2cf3e695a91e22c1d118ceb79e718899d0075618a16bcd3c
|
7
|
+
data.tar.gz: bc6adffb1608d105d4aface08d72a4afb00ae29feed3f07cbd1e0f11cfd8eed0c1197aa2e879848749432f6c2921ef2145df8bc9f2aa9a8fddc53849396db80f
|
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -26,7 +26,7 @@ Your config file should look like:
|
|
26
26
|
|
27
27
|
## Supported Rubies
|
28
28
|
|
29
|
-
* Ruby 1.8.7 through Ruby 2.
|
29
|
+
* Ruby 1.8.7 through Ruby 2.3
|
30
30
|
|
31
31
|
## Supported Application Servers
|
32
32
|
|
@@ -39,4 +39,4 @@ Your config file should look like:
|
|
39
39
|
|
40
40
|
## Help
|
41
41
|
|
42
|
-
|
42
|
+
See our [help site](http://help.apm.scoutapp.com/) or email support@scoutapp.com if you need a hand.
|
@@ -8,7 +8,7 @@ module ScoutApm
|
|
8
8
|
|
9
9
|
def init_logger
|
10
10
|
begin
|
11
|
-
@log_file ||=
|
11
|
+
@log_file ||= determine_log_destination
|
12
12
|
rescue => e
|
13
13
|
end
|
14
14
|
|
@@ -43,13 +43,25 @@ module ScoutApm
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
|
46
|
+
def determine_log_destination
|
47
|
+
case true
|
48
|
+
when wants_stdout? then STDOUT
|
49
|
+
when wants_stderr? then STDERR
|
50
|
+
else "#{log_file_path}/scout_apm.log"
|
51
|
+
end
|
48
52
|
end
|
49
53
|
|
50
54
|
def wants_stdout?
|
51
55
|
config.value('log_file_path').to_s.upcase == 'STDOUT' || environment.platform_integration.log_to_stdout?
|
52
56
|
end
|
57
|
+
|
58
|
+
def wants_stderr?
|
59
|
+
config.value('log_file_path').to_s.upcase == 'STDERR'
|
60
|
+
end
|
61
|
+
|
62
|
+
def log_file_path
|
63
|
+
config.value('log_file_path') || default_log_path
|
64
|
+
end
|
53
65
|
end
|
54
66
|
include Logging
|
55
67
|
end
|
@@ -59,7 +59,7 @@ module ScoutApm
|
|
59
59
|
def log_with_scout_instruments(*args, &block)
|
60
60
|
sql, name = args
|
61
61
|
self.class.instrument("ActiveRecord",
|
62
|
-
Utils::ActiveRecordMetricName.new(sql, name)
|
62
|
+
Utils::ActiveRecordMetricName.new(sql, name),
|
63
63
|
:desc => Utils::SqlSanitizer.new(sql) ) do
|
64
64
|
log_without_scout_instruments(sql, name, &block)
|
65
65
|
end
|
@@ -54,13 +54,16 @@ module ScoutApm
|
|
54
54
|
{:scope => scope_layer.legacy_metric_name}
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
# we don't need to use the full metric name for scoped metrics as we only display metrics aggregrated
|
58
|
+
# by type.
|
59
|
+
metric_name = meta_options.has_key?(:scope) ? layer.type : layer.legacy_metric_name
|
60
|
+
|
61
|
+
meta = MetricMeta.new(metric_name, meta_options)
|
58
62
|
metric_hash[meta] ||= MetricStats.new( meta_options.has_key?(:scope) )
|
59
63
|
|
60
64
|
stat = metric_hash[meta]
|
61
65
|
stat.update!(layer.total_call_time, layer.total_exclusive_time)
|
62
66
|
end
|
63
|
-
|
64
67
|
metric_hash
|
65
68
|
end
|
66
69
|
end
|
@@ -87,14 +90,15 @@ module ScoutApm
|
|
87
90
|
class LayerSlowTransactionConverter < LayerConverterBase
|
88
91
|
def call
|
89
92
|
policy = ScoutApm::Agent.instance.slow_request_policy.capture_type(root_layer.total_call_time)
|
90
|
-
|
91
|
-
|
92
|
-
when ScoutApm::SlowRequestPolicy::CAPTURE_SUMMARY
|
93
|
-
return [nil, {}]
|
94
|
-
when ScoutApm::SlowRequestPolicy::CAPTURE_NONE
|
95
|
-
return [nil, {}]
|
93
|
+
if policy == ScoutApm::SlowRequestPolicy::CAPTURE_NONE
|
94
|
+
return [nil, {}]
|
96
95
|
end
|
97
96
|
|
97
|
+
# increment the slow transaction count if this is a slow transaction.
|
98
|
+
meta = MetricMeta.new("SlowTransaction/#{scope_layer.legacy_metric_name}")
|
99
|
+
stat = MetricStats.new
|
100
|
+
stat.update!(1)
|
101
|
+
|
98
102
|
scope = scope_layer
|
99
103
|
return [nil, {}] unless scope
|
100
104
|
|
@@ -104,10 +108,6 @@ module ScoutApm
|
|
104
108
|
# Disable stackprof output for now
|
105
109
|
stackprof = [] # request.stackprof
|
106
110
|
|
107
|
-
meta = MetricMeta.new("SlowTransaction/#{scope_layer.legacy_metric_name}")
|
108
|
-
stat = MetricStats.new
|
109
|
-
stat.update!(1)
|
110
|
-
|
111
111
|
[
|
112
112
|
SlowTransaction.new(uri,
|
113
113
|
scope.legacy_metric_name,
|
@@ -8,7 +8,6 @@ module ScoutApm
|
|
8
8
|
class SlowRequestPolicy
|
9
9
|
CAPTURE_TYPES = [
|
10
10
|
CAPTURE_DETAIL = "capture_detail",
|
11
|
-
CAPTURE_SUMMARY = "capture_summary",
|
12
11
|
CAPTURE_NONE = "capture_none",
|
13
12
|
]
|
14
13
|
|
@@ -16,8 +15,11 @@ module ScoutApm
|
|
16
15
|
SLOW_REQUEST_TIME_THRESHOLD = 2.0 # seconds
|
17
16
|
|
18
17
|
def capture_type(time)
|
19
|
-
|
20
|
-
|
18
|
+
if !slow_enough?(time)
|
19
|
+
CAPTURE_NONE
|
20
|
+
else
|
21
|
+
CAPTURE_DETAIL
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
data/lib/scout_apm/store.rb
CHANGED
@@ -15,10 +15,14 @@ module ScoutApm
|
|
15
15
|
StoreReportingPeriodTimestamp.new
|
16
16
|
end
|
17
17
|
|
18
|
+
def current_period
|
19
|
+
reporting_periods[current_timestamp]
|
20
|
+
end
|
21
|
+
|
18
22
|
# Save newly collected metrics
|
19
23
|
def track!(metrics, options={})
|
20
24
|
@mutex.synchronize {
|
21
|
-
|
25
|
+
current_period.merge_metrics!(metrics)
|
22
26
|
}
|
23
27
|
end
|
24
28
|
|
@@ -33,7 +37,7 @@ module ScoutApm
|
|
33
37
|
def track_slow_transaction!(slow_transaction)
|
34
38
|
return unless slow_transaction
|
35
39
|
@mutex.synchronize {
|
36
|
-
|
40
|
+
current_period.merge_slow_transactions!(slow_transaction)
|
37
41
|
}
|
38
42
|
end
|
39
43
|
|
@@ -89,7 +93,7 @@ module ScoutApm
|
|
89
93
|
|
90
94
|
# One period of Storage. Typically 1 minute
|
91
95
|
class StoreReportingPeriod
|
92
|
-
#
|
96
|
+
# A SlowTransactionSet object.
|
93
97
|
attr_reader :slow_transactions
|
94
98
|
|
95
99
|
# A StoreReportingPeriodTimestamp representing the time that this
|
@@ -142,21 +146,6 @@ module ScoutApm
|
|
142
146
|
|
143
147
|
private
|
144
148
|
|
145
|
-
# Removes payloads from slow transactions that exceed +SlowRequestPolicy::MAX_DETAIL_PER_MINUTE+ to avoid
|
146
|
-
# bloating the layaway file.
|
147
|
-
def trim_slow_transaction_metrics
|
148
|
-
count_with_metrics = 0
|
149
|
-
@slow_transactions.each do |s|
|
150
|
-
|
151
|
-
if s.has_metrics?
|
152
|
-
count_with_metrics += 1
|
153
|
-
if count_with_metrics > SlowRequestPolicy::MAX_DETAIL_PER_MINUTE
|
154
|
-
s.clear_metrics!
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
149
|
# We can't aggregate CPU, Memory, Capacity, or Controller, so pass through these metrics directly
|
161
150
|
# TODO: Figure out a way to not have this duplicate what's in Samplers, and also on server's ingest
|
162
151
|
PASSTHROUGH_METRICS = ["CPU", "Memory", "Instance", "Controller", "SlowTransaction"]
|
data/lib/scout_apm/tracer.rb
CHANGED
@@ -14,7 +14,7 @@ module ScoutApm
|
|
14
14
|
|
15
15
|
module ClassMethods
|
16
16
|
# Type: the Layer type - "View" or similar
|
17
|
-
# Name: specific name - "users/_gravatar"
|
17
|
+
# Name: specific name - "users/_gravatar". The object must respond to "#to_s". This allows us to be more efficient - in most cases, the metric name isn't needed unless we are processing a slow transaction.
|
18
18
|
# A Block: The code to be instrumented
|
19
19
|
#
|
20
20
|
# Options:
|
@@ -16,7 +16,7 @@ module ScoutApm
|
|
16
16
|
# sql: SELECT "places".* FROM "places" ORDER BY "places"."position" ASC
|
17
17
|
# name: Place Load
|
18
18
|
# metric_name: Place/find
|
19
|
-
def
|
19
|
+
def to_s
|
20
20
|
return DEFAULT_METRIC unless name
|
21
21
|
return DEFAULT_METRIC unless model && operation
|
22
22
|
|
data/lib/scout_apm/version.rb
CHANGED
@@ -9,7 +9,7 @@ class ActiveRecordMetricNameTest < Minitest::Test
|
|
9
9
|
name = :skip_logging
|
10
10
|
|
11
11
|
mn = ScoutApm::Utils::ActiveRecordMetricName.new(sql, name)
|
12
|
-
assert_equal "SQL/Unknown", mn.
|
12
|
+
assert_equal "SQL/Unknown", mn.to_s
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_postgres_column_lookup
|
@@ -27,7 +27,7 @@ class ActiveRecordMetricNameTest < Minitest::Test
|
|
27
27
|
name = "SCHEMA"
|
28
28
|
|
29
29
|
mn = ScoutApm::Utils::ActiveRecordMetricName.new(sql, name)
|
30
|
-
assert_equal "SQL/Unknown", mn.
|
30
|
+
assert_equal "SQL/Unknown", mn.to_s
|
31
31
|
end
|
32
32
|
|
33
33
|
|
@@ -36,7 +36,7 @@ class ActiveRecordMetricNameTest < Minitest::Test
|
|
36
36
|
name = "User Load"
|
37
37
|
|
38
38
|
mn = ScoutApm::Utils::ActiveRecordMetricName.new(sql, name)
|
39
|
-
assert_equal "User/find", mn.
|
39
|
+
assert_equal "User/find", mn.to_s
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_without_name
|
@@ -44,7 +44,7 @@ class ActiveRecordMetricNameTest < Minitest::Test
|
|
44
44
|
name = nil
|
45
45
|
|
46
46
|
mn = ScoutApm::Utils::ActiveRecordMetricName.new(sql, name)
|
47
|
-
assert_equal "SQL/Unknown", mn.
|
47
|
+
assert_equal "SQL/Unknown", mn.to_s
|
48
48
|
end
|
49
49
|
|
50
50
|
# TODO: Determine if there should be a distinction between Unknown and Other.
|
@@ -53,6 +53,6 @@ class ActiveRecordMetricNameTest < Minitest::Test
|
|
53
53
|
name = "A whole sentance describing what's what"
|
54
54
|
|
55
55
|
mn = ScoutApm::Utils::ActiveRecordMetricName.new(sql, name)
|
56
|
-
assert_equal "SQL/other", mn.
|
56
|
+
assert_equal "SQL/other", mn.to_s
|
57
57
|
end
|
58
58
|
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: 1.
|
4
|
+
version: 1.3.0
|
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: 2016-02-
|
12
|
+
date: 2016-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|