scout_rails 1.1.3 → 1.1.4.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/scout_rails/agent/reporting.rb +5 -6
- data/lib/scout_rails/store.rb +18 -0
- data/lib/scout_rails/version.rb +1 -1
- metadata +5 -5
@@ -17,10 +17,12 @@ module ScoutRails
|
|
17
17
|
if meta.metric_name =~ /\AController/
|
18
18
|
controller_count += stats.call_count
|
19
19
|
end
|
20
|
-
end
|
21
|
-
|
20
|
+
end
|
21
|
+
sample, samples = store.fetch_and_reset_samples!
|
22
|
+
payload = Marshal.dump(:metrics => metrics, :sample => sample, :samples => samples)
|
23
|
+
logger.debug "#{config.settings['name']} Delivering payload [#{payload.size/1024} KB] for #{controller_count} requests and #{samples.size} slow transaction samples of durations: #{samples.map(&:total_call_time).join(',')}."
|
22
24
|
response = post( checkin_uri,
|
23
|
-
|
25
|
+
payload,
|
24
26
|
"Content-Type" => "application/json" )
|
25
27
|
if response and response.is_a?(Net::HTTPSuccess)
|
26
28
|
directives = Marshal.load(response.body)
|
@@ -29,9 +31,6 @@ module ScoutRails
|
|
29
31
|
logger.info "Resetting metric_lookup."
|
30
32
|
self.metric_lookup = Hash.new
|
31
33
|
end
|
32
|
-
store.transaction_sample_lock.synchronize do
|
33
|
-
store.sample = nil
|
34
|
-
end
|
35
34
|
logger.debug "Metric Cache Size: #{metric_lookup.size}"
|
36
35
|
end
|
37
36
|
end
|
data/lib/scout_rails/store.rb
CHANGED
@@ -9,6 +9,7 @@ class ScoutRails::Store
|
|
9
9
|
attr_accessor :transaction_hash
|
10
10
|
attr_accessor :stack
|
11
11
|
attr_accessor :sample
|
12
|
+
attr_accessor :samples # array of slow transaction samples
|
12
13
|
attr_reader :transaction_sample_lock
|
13
14
|
|
14
15
|
def initialize
|
@@ -19,6 +20,7 @@ class ScoutRails::Store
|
|
19
20
|
@stack = Array.new
|
20
21
|
# ensure background thread doesn't manipulate transaction sample while the store is.
|
21
22
|
@transaction_sample_lock = Mutex.new
|
23
|
+
@samples = Array.new
|
22
24
|
end
|
23
25
|
|
24
26
|
# Called when the last stack item completes for the current transaction to clear
|
@@ -126,12 +128,28 @@ class ScoutRails::Store
|
|
126
128
|
end
|
127
129
|
|
128
130
|
# Stores the slowest transaction. This will be sent to the server.
|
131
|
+
# Includes the legacy single slow transaction and the array of samples.
|
129
132
|
def store_sample(uri,transaction_hash,parent_meta,parent_stat,options = {})
|
130
133
|
@transaction_sample_lock.synchronize do
|
131
134
|
if parent_stat.total_call_time >= 2 and (@sample.nil? or (@sample and parent_stat.total_call_time > @sample.total_call_time))
|
132
135
|
@sample = ScoutRails::TransactionSample.new(uri,parent_meta.metric_name,parent_stat.total_call_time,transaction_hash.dup)
|
133
136
|
end
|
137
|
+
# tree map of all slow transactions
|
138
|
+
if parent_stat.total_call_time >= 2
|
139
|
+
@samples.push(ScoutRails::TransactionSample.new(uri,parent_meta.metric_name,parent_stat.total_call_time,transaction_hash.dup))
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns the slow samples and resets the values - used when reporting.
|
145
|
+
def fetch_and_reset_samples!
|
146
|
+
sample = @sample
|
147
|
+
samples = @samples
|
148
|
+
@transaction_sample_lock.synchronize do
|
149
|
+
self.sample = nil
|
150
|
+
self.samples = Array.new
|
134
151
|
end
|
152
|
+
[sample,samples]
|
135
153
|
end
|
136
154
|
|
137
155
|
# Finds or creates the metric w/the given name in the metric_hash, and updates the time. Primarily used to
|
data/lib/scout_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.4.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Derek Haynes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Monitors a Ruby on Rails application and reports detailed metrics on
|
16
16
|
performance to Scout, a hosted monitoring service.
|
@@ -67,9 +67,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
69
69
|
requirements:
|
70
|
-
- - ! '
|
70
|
+
- - ! '>'
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
72
|
+
version: 1.3.1
|
73
73
|
requirements: []
|
74
74
|
rubyforge_project: scout_rails
|
75
75
|
rubygems_version: 1.8.23
|