scout_apm 1.2.7 → 1.2.8.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -0
- data/lib/scout_apm/agent.rb +10 -4
- data/lib/scout_apm/background_worker.rb +15 -2
- data/lib/scout_apm/layaway.rb +13 -1
- data/lib/scout_apm/store.rb +20 -3
- data/lib/scout_apm/tracked_request.rb +2 -0
- data/lib/scout_apm/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 648de873df09b8d7419abd803d9180fb67e1595d
|
|
4
|
+
data.tar.gz: 61cf23bc15c91ba74022f8390348cf4896bfd9d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8856fc5d888b1a6243b16e2b04d1d4d60f84167d1dea79032e504d6b21f2fb43292df433cb6c5b99454c39fa529529d5f534880b8867d7a3446834228c164366
|
|
7
|
+
data.tar.gz: c7142c814ad6c572381688dea1baf5fdcd6f968bd6d79dff59fb7bfe68fb1e6822abf22d3ff8e0ec8d24e9bc6e1cfca748cb91e7091914ea65fe1cf0897678c1
|
data/CHANGELOG.markdown
CHANGED
data/lib/scout_apm/agent.rb
CHANGED
|
@@ -152,15 +152,21 @@ module ScoutApm
|
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
-
# Called via an at_exit handler, it
|
|
156
|
-
#
|
|
157
|
-
#
|
|
155
|
+
# Called via an at_exit handler, it:
|
|
156
|
+
# (1) Stops the background worker
|
|
157
|
+
# (2) Stores metrics locally (forcing current-minute metrics to be written)
|
|
158
|
+
# It does not attempt to actually report metrics.
|
|
158
159
|
def shutdown
|
|
160
|
+
logger.info "Shutting down ScoutApm"
|
|
159
161
|
return if !started?
|
|
160
162
|
if @background_worker
|
|
161
163
|
@background_worker.stop
|
|
162
|
-
|
|
164
|
+
store.write_to_layaway(layaway, :force)
|
|
163
165
|
end
|
|
166
|
+
|
|
167
|
+
# Make sure we don't exit the process while the background worker is running its task.
|
|
168
|
+
logger.debug "Joining background worker thread"
|
|
169
|
+
@background_worker_thread.join if @background_worker_thread
|
|
164
170
|
end
|
|
165
171
|
|
|
166
172
|
def started?
|
|
@@ -23,20 +23,33 @@ module ScoutApm
|
|
|
23
23
|
# Starts running the passed block every 60 seconds (starting now).
|
|
24
24
|
def start(&block)
|
|
25
25
|
@task = block
|
|
26
|
+
|
|
26
27
|
begin
|
|
27
28
|
ScoutApm::Agent.instance.logger.debug "Starting Background Worker, running every #{period} seconds"
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
# The first run should be 1 period of time from now
|
|
31
|
+
next_time = Time.now + period
|
|
32
|
+
|
|
33
|
+
loop do
|
|
30
34
|
now = Time.now
|
|
35
|
+
|
|
36
|
+
# Sleep the correct amount of time to reach next_time
|
|
31
37
|
while now < next_time
|
|
32
38
|
sleep_time = next_time - now
|
|
33
39
|
sleep(sleep_time) if sleep_time > 0
|
|
34
40
|
now = Time.now
|
|
35
41
|
end
|
|
42
|
+
|
|
43
|
+
# Bail out if @keep_running is false
|
|
44
|
+
break unless @keep_running
|
|
45
|
+
|
|
36
46
|
@task.call
|
|
47
|
+
|
|
48
|
+
# Adjust the next time to run forward by @periods until it is in the future
|
|
37
49
|
while next_time <= now
|
|
38
50
|
next_time += period
|
|
39
51
|
end
|
|
52
|
+
|
|
40
53
|
end
|
|
41
54
|
rescue
|
|
42
55
|
ScoutApm::Agent.instance.logger.debug "Background Worker Exception!"
|
data/lib/scout_apm/layaway.rb
CHANGED
|
@@ -11,9 +11,18 @@ module ScoutApm
|
|
|
11
11
|
def add_reporting_period(time, reporting_period)
|
|
12
12
|
file.read_and_write do |existing_data|
|
|
13
13
|
existing_data ||= Hash.new
|
|
14
|
-
|
|
14
|
+
ScoutApm::Agent.instance.logger.debug("AddReportingPeriod: Adding a reporting_period with timestamp: #{reporting_period.timestamp.to_s}, and #{reporting_period.request_count} requests")
|
|
15
|
+
|
|
16
|
+
existing_data = existing_data.merge(time => reporting_period) {|key, old_val, new_val|
|
|
17
|
+
old_req = old_val.request_count
|
|
18
|
+
new_req = new_val.request_count
|
|
19
|
+
ScoutApm::Agent.instance.logger.debug("Merging Two reporting periods (#{old_val.timestamp.to_s}, #{new_val.timestamp.to_s}): old req #{old_req}, new req #{new_req}")
|
|
20
|
+
|
|
15
21
|
old_val.merge_metrics!(new_val.metrics_payload).merge_slow_transactions!(new_val.slow_transactions)
|
|
16
22
|
}
|
|
23
|
+
|
|
24
|
+
ScoutApm::Agent.instance.logger.debug("AddReportingPeriod: AfterMerge Timestamps: #{existing_data.keys.map(&:to_s).inspect}")
|
|
25
|
+
existing_data
|
|
17
26
|
end
|
|
18
27
|
end
|
|
19
28
|
|
|
@@ -24,6 +33,9 @@ module ScoutApm
|
|
|
24
33
|
ready_for_delivery = []
|
|
25
34
|
file.read_and_write do |existing_data|
|
|
26
35
|
existing_data ||= {}
|
|
36
|
+
|
|
37
|
+
ScoutApm::Agent.instance.logger.debug("PeriodsReadyForDeliver: All Timestamps: #{existing_data.keys.map(&:to_s).inspect}")
|
|
38
|
+
|
|
27
39
|
ready_for_delivery = existing_data.to_a.select {|time, rp| should_send?(rp) } # Select off the values we want. to_a is needed for compatibility with Ruby 1.8.7.
|
|
28
40
|
|
|
29
41
|
# Rewrite anything not plucked out back to the file
|
data/lib/scout_apm/store.rb
CHANGED
|
@@ -38,14 +38,21 @@ module ScoutApm
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
# Take each completed reporting_period, and write it to the layaway passed
|
|
41
|
-
|
|
41
|
+
#
|
|
42
|
+
# force - a boolean argument that forces this function to write
|
|
43
|
+
# current-minute metrics. Useful when we are shutting down the agent
|
|
44
|
+
# during a restart.
|
|
45
|
+
def write_to_layaway(layaway, force=false)
|
|
46
|
+
ScoutApm::Agent.instance.logger.debug("Writing to layaway#{" (Forced)" if force}")
|
|
47
|
+
|
|
42
48
|
@mutex.synchronize {
|
|
43
|
-
reporting_periods.select { |time, rp| time.timestamp < current_timestamp.timestamp}.
|
|
49
|
+
reporting_periods.select { |time, rp| force || time.timestamp < current_timestamp.timestamp}.
|
|
44
50
|
each { |time, rp|
|
|
45
51
|
layaway.add_reporting_period(time, rp)
|
|
46
52
|
reporting_periods.delete(time)
|
|
47
53
|
}
|
|
48
54
|
}
|
|
55
|
+
ScoutApm::Agent.instance.logger.debug("Finished writing to layaway")
|
|
49
56
|
end
|
|
50
57
|
end
|
|
51
58
|
|
|
@@ -60,7 +67,7 @@ module ScoutApm
|
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
def to_s
|
|
63
|
-
@
|
|
70
|
+
Time.at(@timestamp).iso8601
|
|
64
71
|
end
|
|
65
72
|
|
|
66
73
|
def eql?(o)
|
|
@@ -123,6 +130,16 @@ module ScoutApm
|
|
|
123
130
|
@slow_transactions.to_a
|
|
124
131
|
end
|
|
125
132
|
|
|
133
|
+
#################################
|
|
134
|
+
# Debug Helpers
|
|
135
|
+
#################################
|
|
136
|
+
|
|
137
|
+
def request_count
|
|
138
|
+
metrics_payload.
|
|
139
|
+
select { |meta,stats| meta.metric_name =~ /\AController/ }.
|
|
140
|
+
inject(0) {|sum, (_, stat)| sum + stat.call_count }
|
|
141
|
+
end
|
|
142
|
+
|
|
126
143
|
private
|
|
127
144
|
|
|
128
145
|
# Removes payloads from slow transactions that exceed +SlowRequestPolicy::MAX_DETAIL_PER_MINUTE+ to avoid
|
|
@@ -139,6 +139,8 @@ module ScoutApm
|
|
|
139
139
|
|
|
140
140
|
queue_time_metrics = RequestQueueTime.new(self).call
|
|
141
141
|
ScoutApm::Agent.instance.store.track!(queue_time_metrics)
|
|
142
|
+
|
|
143
|
+
# ScoutApm::Agent.instance.logger.debug("Finished recording request") if metrics.any?
|
|
142
144
|
end
|
|
143
145
|
|
|
144
146
|
# Have we already persisted this request?
|
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.
|
|
4
|
+
version: 1.2.8.pre1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Derek Haynes
|
|
@@ -170,12 +170,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
170
170
|
version: '0'
|
|
171
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
requirements:
|
|
173
|
-
- - "
|
|
173
|
+
- - ">"
|
|
174
174
|
- !ruby/object:Gem::Version
|
|
175
|
-
version:
|
|
175
|
+
version: 1.3.1
|
|
176
176
|
requirements: []
|
|
177
177
|
rubyforge_project: scout_apm
|
|
178
|
-
rubygems_version: 2.
|
|
178
|
+
rubygems_version: 2.2.2
|
|
179
179
|
signing_key:
|
|
180
180
|
specification_version: 4
|
|
181
181
|
summary: Ruby application performance monitoring
|