scout_apm 1.2.0.pre9 → 1.2.0.pre10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scout_apm/agent/reporting.rb +4 -0
- data/lib/scout_apm/background_worker.rb +1 -1
- data/lib/scout_apm/layaway.rb +1 -2
- data/lib/scout_apm/layer_converter.rb +2 -2
- data/lib/scout_apm/request_queue_time.rb +3 -0
- data/lib/scout_apm/store.rb +23 -35
- data/lib/scout_apm/version.rb +1 -1
- 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: c329d301fd9c8155277eb3be6398d8e357284e72
|
4
|
+
data.tar.gz: de1c84ebc4232d67a1f9e4a7d6e9de1c93b5202a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc8796324d43f82e2c54600a97adc8dc3f5dfe2151cb4ca1884167595ab592baff6e71ece59ebdef6b3761ddfe1f58a4df48841426c02f366151c38579659a5c
|
7
|
+
data.tar.gz: d9d828f8c65d7f0fd3921e581db8cfda64253b4af6d1b2e913daf980061cff650afbead986b24553f18029a58f2416c7e0a1fda8e0268bbb652890471e5e4227
|
@@ -25,8 +25,11 @@ module ScoutApm
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# In a running app, one process will get one period ready for delivery, the others will see 0.
|
28
|
+
MAX_AGE_TO_REPORT = 10.minutes
|
29
|
+
|
28
30
|
def report_to_server
|
29
31
|
reporting_periods = layaway.periods_ready_for_delivery
|
32
|
+
reporting_periods.reject! {|rp| rp.timestamp.age_in_seconds > MAX_AGE_TO_REPORT }
|
30
33
|
reporting_periods.each do |rp|
|
31
34
|
deliver_period(rp)
|
32
35
|
end
|
@@ -40,6 +43,7 @@ module ScoutApm
|
|
40
43
|
:unique_id => ScoutApm::Utils::UniqueId.simple,
|
41
44
|
:agent_version => ScoutApm::VERSION,
|
42
45
|
:agent_time => reporting_period.timestamp.to_s,
|
46
|
+
:agent_pid => Process.pid,
|
43
47
|
}
|
44
48
|
|
45
49
|
log_deliver(metrics, slow_transactions, metadata)
|
@@ -39,7 +39,7 @@ module ScoutApm
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
rescue
|
42
|
-
ScoutApm::Agent.instance.logger.debug "Background Worker Exception
|
42
|
+
ScoutApm::Agent.instance.logger.debug "Background Worker Exception!"
|
43
43
|
ScoutApm::Agent.instance.logger.debug $!.message
|
44
44
|
ScoutApm::Agent.instance.logger.debug $!.backtrace
|
45
45
|
end
|
data/lib/scout_apm/layaway.rb
CHANGED
@@ -27,13 +27,12 @@ module ScoutApm
|
|
27
27
|
file.read_and_write do |existing_data|
|
28
28
|
existing_data ||= Hash.new
|
29
29
|
existing_data.merge(time => reporting_period) {|key, old_val, new_val|
|
30
|
-
old_val.merge_metrics!(new_val.
|
30
|
+
old_val.merge_metrics!(new_val.metrics_payload).merge_slow_transactions!(new_val.slow_transactions)
|
31
31
|
}
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
REPORTING_INTERVAL = 60 # seconds
|
36
|
-
MAX_INTERVALS = 5
|
37
36
|
|
38
37
|
# Returns an array of ReportingPeriod objects that are ready to be pushed to the server
|
39
38
|
def periods_ready_for_delivery
|
@@ -140,16 +140,16 @@ module ScoutApm
|
|
140
140
|
{:scope => scope_layer.legacy_metric_name}
|
141
141
|
end
|
142
142
|
|
143
|
-
meta_options.merge!(:desc => layer.desc) if layer.desc
|
144
143
|
|
145
144
|
# Specific Metric
|
145
|
+
meta_options.merge!(:desc => layer.desc) if layer.desc
|
146
146
|
meta = MetricMeta.new(layer.legacy_metric_name, meta_options)
|
147
147
|
meta.extra.merge!(:backtrace => layer.backtrace) if layer.backtrace
|
148
148
|
metric_hash[meta] ||= MetricStats.new( meta_options.has_key?(:scope) )
|
149
149
|
stat = metric_hash[meta]
|
150
150
|
stat.update!(layer.total_call_time, layer.total_exclusive_time)
|
151
151
|
|
152
|
-
# Merged Metric (no specifics, just sum up by type
|
152
|
+
# Merged Metric (no specifics, just sum up by type)
|
153
153
|
meta = MetricMeta.new("#{layer.type}/all")
|
154
154
|
metric_hash[meta] ||= MetricStats.new(false)
|
155
155
|
stat = metric_hash[meta]
|
@@ -20,6 +20,9 @@ module ScoutApm
|
|
20
20
|
request_start = root_layer.start_time
|
21
21
|
queue_time = (request_start - parsed_start).to_f
|
22
22
|
|
23
|
+
# If we end up with a negative value, just bail out and don't report anything
|
24
|
+
return {} if queue_time < 0
|
25
|
+
|
23
26
|
meta = MetricMeta.new("QueueTime/Request", {:scope => scope_layer.legacy_metric_name})
|
24
27
|
stat = MetricStats.new(true)
|
25
28
|
stat.update!(queue_time)
|
data/lib/scout_apm/store.rb
CHANGED
@@ -40,10 +40,10 @@ module ScoutApm
|
|
40
40
|
def write_to_layaway(layaway)
|
41
41
|
@mutex.synchronize {
|
42
42
|
reporting_periods.select { |time, rp| time.timestamp < current_timestamp.timestamp}.
|
43
|
-
each
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
each { |time, rp|
|
44
|
+
layaway.add_reporting_period(time, rp)
|
45
|
+
reporting_periods.delete(time)
|
46
|
+
}
|
47
47
|
}
|
48
48
|
end
|
49
49
|
end
|
@@ -77,17 +77,6 @@ module ScoutApm
|
|
77
77
|
|
78
78
|
# One period of Storage. Typically 1 minute
|
79
79
|
class StoreReportingPeriod
|
80
|
-
# A hash of { MetricMeta => MetricStat }
|
81
|
-
# This holds metrics for specific parts of the application.
|
82
|
-
# "Controller/user/index", "ActiveRecord/SQL/users/find", "View/users/_gravatar" and similar.
|
83
|
-
#
|
84
|
-
# If over the course of a minute a metric is called more than once (very likely), it will be
|
85
|
-
# combined with the others of the same type, and summed/calculated. The merging logic is in
|
86
|
-
# MetricStats
|
87
|
-
#
|
88
|
-
# Use the accessor function `metrics_payload` for most uses. It includes the calculated aggregate values
|
89
|
-
attr_reader :metrics
|
90
|
-
|
91
80
|
# An array of SlowTransaction objects
|
92
81
|
attr_reader :slow_transactions
|
93
82
|
|
@@ -96,16 +85,17 @@ module ScoutApm
|
|
96
85
|
attr_reader :timestamp
|
97
86
|
|
98
87
|
def initialize(timestamp)
|
99
|
-
@metrics = Hash.new
|
100
|
-
@slow_transactions = Array.new
|
101
88
|
@timestamp = timestamp
|
89
|
+
|
90
|
+
@slow_transactions = Array.new
|
91
|
+
@aggregate_metrics = Hash.new
|
102
92
|
end
|
103
93
|
|
104
94
|
#################################
|
105
95
|
# Add metrics as they are recorded
|
106
96
|
#################################
|
107
97
|
def merge_metrics!(metrics)
|
108
|
-
|
98
|
+
metrics.each { |metric| absorb(metric) }
|
109
99
|
self
|
110
100
|
end
|
111
101
|
|
@@ -118,7 +108,7 @@ module ScoutApm
|
|
118
108
|
# Retrieve Metrics for reporting
|
119
109
|
#################################
|
120
110
|
def metrics_payload
|
121
|
-
aggregate_metrics
|
111
|
+
@aggregate_metrics
|
122
112
|
end
|
123
113
|
|
124
114
|
def slow_transactions_payload
|
@@ -136,22 +126,20 @@ module ScoutApm
|
|
136
126
|
# A hash of { MetricMeta => MetricStat }
|
137
127
|
# This represents the aggregate metrics over the course of the minute.
|
138
128
|
# "ActiveRecord/all", "View/all", "HTTP/all" and similar
|
139
|
-
def
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
hsh
|
129
|
+
def absorb(metric)
|
130
|
+
meta, stat = metric
|
131
|
+
|
132
|
+
if PASSTHROUGH_METRICS.include?(meta.type) # Leave as-is, don't attempt to combine
|
133
|
+
@aggregate_metrics[meta] = stat
|
134
|
+
elsif meta.type == "Errors" # Sadly special cased, we want both raw and aggregate values
|
135
|
+
@aggregate_metrics[meta] = stat
|
136
|
+
agg_meta = MetricMeta.new("Errors/Request", :scope => meta.scope)
|
137
|
+
@aggregate_metrics[agg_meta] ||= MetricStats.new
|
138
|
+
@aggregate_metrics[agg_meta].combine!(stat)
|
139
|
+
else # Combine down to a single /all key
|
140
|
+
agg_meta = MetricMeta.new("#{meta.type}/all", :scope => meta.scope)
|
141
|
+
@aggregate_metrics[agg_meta] ||= MetricStats.new
|
142
|
+
@aggregate_metrics[agg_meta].combine!(stat)
|
155
143
|
end
|
156
144
|
end
|
157
145
|
end
|
data/lib/scout_apm/version.rb
CHANGED
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.2.0.
|
4
|
+
version: 1.2.0.pre10
|
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: 2015-12-
|
12
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|