right_support 2.8.22 → 2.8.23

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.8.22
1
+ 2.8.23
@@ -128,7 +128,10 @@ module RightSupport::Stats
128
128
  #
129
129
  # @return [Float, NilClass] Recent average rate, or nil if total is 0
130
130
  def avg_rate
131
- 1.0 / average(@interval, Time.now - @last_start_time) if @measure_rate && @total > 0
131
+ if @measure_rate && @total > 0
132
+ interval = average(@interval, Time.now - @last_start_time)
133
+ interval == 0.0 ? 0.0 : 1.0 / interval
134
+ end
132
135
  end
133
136
 
134
137
  # Get average duration of activity
@@ -136,7 +139,7 @@ module RightSupport::Stats
136
139
  # @return [Float, NilClass] Average duration in seconds of activity weighted
137
140
  # toward past activity, or nil if total is 0
138
141
  def avg_duration
139
- @avg_duration if @total > 0
142
+ @avg_duration
140
143
  end
141
144
 
142
145
  # Get stats about last activity
@@ -66,7 +66,13 @@ module RightSupport::Stats
66
66
  # @return [TrueClass] Always return true
67
67
  def track(category, exception, message = nil)
68
68
  begin
69
- @callback.call(exception, message, @server) if @server && @callback && message
69
+ if @callback && @server
70
+ if @callback.respond_to?(:arity) && @callback.arity.abs == 4
71
+ @callback.call(exception, message, @server, category)
72
+ else
73
+ @callback.call(exception, message, @server)
74
+ end
75
+ end
70
76
  @stats ||= {}
71
77
  exceptions = (@stats[category] ||= {"total" => 0, "recent" => []})
72
78
  exceptions["total"] += 1
@@ -285,6 +285,7 @@ module RightSupport
285
285
  # "exceptions" [Hash, NilClass] Exceptions raised per category, or nil if none
286
286
  # "total"(Integer):: Total exceptions for this category
287
287
  # "recent"(Array):: Most recent as a hash of "count", "type", "message", "when", and "where"
288
+ # (exceptions is omitted from display if there is no hash entry for it)
288
289
  # "heartbeat" [Integer, NilClass] Number of seconds between AMQP heartbeats, or nil if heartbeat disabled
289
290
  # "returns" [Hash, NilClass] Message return activity stats with keys "total", "percent", "last", and "rate"
290
291
  # with percentage breakdown per request type, or nil if none
@@ -321,13 +322,18 @@ module RightSupport
321
322
  str += "#{b["alias"]}: #{b["identity"]} #{b["status"]}, disconnects: #{disconnects}, failures: #{failures}\n"
322
323
  str += value_indent
323
324
  end
324
- str += sprintf("%-#{sub_name_width}s#{SEPARATOR}", "exceptions")
325
- str += if brokers["exceptions"].nil? || brokers["exceptions"].empty?
326
- "none\n"
327
- else
328
- exceptions_str(brokers["exceptions"], sub_value_indent, options) + "\n"
325
+
326
+ # Exceptions are accumulated globally for agents at right_agent 2.3 or above
327
+ if brokers.has_key?("exceptions")
328
+ str += sprintf("%-#{sub_name_width}s#{SEPARATOR}", "exceptions")
329
+ str += if brokers["exceptions"].nil? || brokers["exceptions"].empty?
330
+ "none\n"
331
+ else
332
+ exceptions_str(brokers["exceptions"], sub_value_indent, options) + "\n"
333
+ end
334
+ str += value_indent
329
335
  end
330
- str += value_indent
336
+
331
337
  str += sprintf("%-#{sub_name_width}s#{SEPARATOR}", "heartbeat")
332
338
  str += if [nil, 0].include?(brokers["heartbeat"])
333
339
  "none\n"
@@ -381,7 +387,7 @@ module RightSupport
381
387
  if v.is_a?(Numeric)
382
388
  str = k =~ /age$/ ? elapsed(v) : enough_precision(v)
383
389
  str += "/sec" if k =~ /rate$/
384
- str += " sec" if k =~ /time$/
390
+ str += " sec" if k =~ /time$|delay$/
385
391
  str += "%" if k =~ /percent$/
386
392
  str
387
393
  elsif v.is_a?(Hash)
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{right_support}
8
- s.version = "2.8.22"
7
+ s.name = "right_support"
8
+ s.version = "2.8.23"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tony Spataro", "Sergey Sergyenko", "Ryan Williamson", "Lee Kirchhoff", "Alexey Karpik", "Scott Messier"]
12
- s.date = %q{2014-04-07}
13
- s.description = %q{A toolkit of useful, reusable foundation code created by RightScale.}
14
- s.email = %q{support@rightscale.com}
12
+ s.date = "2014-05-27"
13
+ s.description = "A toolkit of useful, reusable foundation code created by RightScale."
14
+ s.email = "support@rightscale.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -136,32 +136,31 @@ Gem::Specification.new do |s|
136
136
  "spec/validation/openssl_spec.rb",
137
137
  "spec/validation/ssh_spec.rb"
138
138
  ]
139
- s.homepage = %q{https://github.com/rightscale/right_support}
139
+ s.homepage = "https://github.com/rightscale/right_support"
140
140
  s.licenses = ["MIT"]
141
141
  s.require_paths = ["lib"]
142
- s.rubygems_version = %q{1.3.7}
143
- s.summary = %q{Reusable foundation code.}
142
+ s.rubygems_version = "1.8.26"
143
+ s.summary = "Reusable foundation code."
144
144
 
145
145
  if s.respond_to? :specification_version then
146
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
147
146
  s.specification_version = 3
148
147
 
149
148
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
150
149
  s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
151
150
  s.add_development_dependency(%q<flexmock>, ["~> 1.0"])
152
151
  s.add_development_dependency(%q<rspec>, ["~> 2.13.0"])
153
- s.add_development_dependency(%q<cucumber>, ["~> 1.0", "< 1.3.3"])
152
+ s.add_development_dependency(%q<cucumber>, ["< 1.3.3", "~> 1.0"])
154
153
  else
155
154
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
156
155
  s.add_dependency(%q<flexmock>, ["~> 1.0"])
157
156
  s.add_dependency(%q<rspec>, ["~> 2.13.0"])
158
- s.add_dependency(%q<cucumber>, ["~> 1.0", "< 1.3.3"])
157
+ s.add_dependency(%q<cucumber>, ["< 1.3.3", "~> 1.0"])
159
158
  end
160
159
  else
161
160
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
162
161
  s.add_dependency(%q<flexmock>, ["~> 1.0"])
163
162
  s.add_dependency(%q<rspec>, ["~> 2.13.0"])
164
- s.add_dependency(%q<cucumber>, ["~> 1.0", "< 1.3.3"])
163
+ s.add_dependency(%q<cucumber>, ["< 1.3.3", "~> 1.0"])
165
164
  end
166
165
  end
167
166
 
@@ -187,6 +187,14 @@ describe RightSupport::Stats::Activity do
187
187
  @stats.avg_rate.should == 0.125
188
188
  end
189
189
 
190
+ it "sets rate to 0 if interval is 0" do
191
+ flexmock(Time).should_receive(:now).and_return(1000000, 1000000)
192
+ @stats.avg_rate.should be_nil
193
+ @stats.update
194
+ @stats.instance_variable_get(:@interval).should == 0.0
195
+ @stats.avg_rate.should == 0.0
196
+ end
197
+
190
198
  it "does not compute average unless measuring rate is enabled" do
191
199
  @stats = RightSupport::Stats::Activity.new(false)
192
200
  flexmock(Time).should_receive(:now).and_return(1000010)
@@ -128,6 +128,23 @@ describe RightSupport::Stats::Exceptions do
128
128
  called.should == 1
129
129
  end
130
130
 
131
+ it "includes category parameter in callback if callback supports it" do
132
+ called = 0
133
+ callback = lambda do |exception, message, server, category|
134
+ called += 1
135
+ exception.should == @exception
136
+ message.should == "message"
137
+ server.should == "server"
138
+ category.should == "testing"
139
+ end
140
+ @stats = RightSupport::Stats::Exceptions.new("server", callback)
141
+ @stats.track("testing", @exception, "message")
142
+ @stats.stats.should == {"testing" => {"total" => 1,
143
+ "recent" => [{"count" => 1, "type" => "Exception", "message" => "Test error",
144
+ "when" => @now, "where" => nil}]}}
145
+ called.should == 1
146
+ end
147
+
131
148
  it "catches any exceptions raised internally and log them" do
132
149
  begin
133
150
  logger = flexmock("logger")
@@ -338,6 +338,25 @@ describe RightSupport::Stats do
338
338
  " returns : no queue consumers: 67%, no queue: 33%, total: 3, \n" +
339
339
  " last: no queue consumers (10 sec ago), rate: 1.0/sec\n"
340
340
  end
341
+
342
+ it "omits exceptions from brokers if exceptions key omitted" do
343
+ @brokers.delete("exceptions")
344
+ @brokers["heartbeat"] = 60
345
+ activity = RightSupport::Stats::Activity.new
346
+ activity.update("no queue")
347
+ activity.finish(@now - 10)
348
+ activity.update("no queue consumers")
349
+ activity.update("no queue consumers")
350
+ flexmock(Time).should_receive(:now).and_return(1000010)
351
+ @brokers["returns"] = activity.all
352
+ result = @helpers.brokers_str(@brokers, :name_width => 10)
353
+ result.should == "brokers : b0: rs-broker-localhost-5672 connected, disconnects: none, failures: none\n" +
354
+ " b1: rs-broker-localhost-5673 disconnected, disconnects: 2 (16 min 40 sec ago), failures: none\n" +
355
+ " b2: rs-broker-localhost-5674 failed, disconnects: none, failures: 3 (16 min 40 sec ago w/ 2 retries)\n" +
356
+ " heartbeat : 60 sec\n" +
357
+ " returns : no queue consumers: 67%, no queue: 33%, total: 3, \n" +
358
+ " last: no queue consumers (10 sec ago), rate: 1.0/sec\n"
359
+ end
341
360
  end
342
361
 
343
362
  context "activity_str" do
@@ -482,6 +501,7 @@ describe RightSupport::Stats do
482
501
  "empty_hash" => {},
483
502
  "float_value" => 3.15,
484
503
  "some % percent" => 3.54,
504
+ "some delay" => 0.125,
485
505
  "some time" => 0.675,
486
506
  "some rate" => 4.72,
487
507
  "some age" => 125,
@@ -505,6 +525,7 @@ describe RightSupport::Stats do
505
525
  " float_value : 3.2\n" +
506
526
  " some % : 3.5%\n" +
507
527
  " some age : 2 min 5 sec\n" +
528
+ " some delay : 0.13 sec\n" +
508
529
  " some hash : ants: 100000000, bears: 1, cats: 3, dogs: 2, dragons: none, \n" +
509
530
  " hippopotami: 99, leopards: 25\n" +
510
531
  " some rate : 4.7/sec\n" +
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: right_support
3
- version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 8
9
- - 22
10
- version: 2.8.22
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.8.23
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Tony Spataro
14
9
  - Sergey Sergyenko
15
10
  - Ryan Williamson
@@ -19,89 +14,86 @@ authors:
19
14
  autorequire:
20
15
  bindir: bin
21
16
  cert_chain: []
22
-
23
- date: 2014-04-07 00:00:00 -07:00
24
- default_executable:
25
- dependencies:
26
- - !ruby/object:Gem::Dependency
27
- version_requirements: &id001 !ruby/object:Gem::Requirement
17
+ date: 2014-05-27 00:00:00.000000000 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: jeweler
21
+ requirement: !ruby/object:Gem::Requirement
28
22
  none: false
29
- requirements:
23
+ requirements:
30
24
  - - ~>
31
- - !ruby/object:Gem::Version
32
- hash: 3
33
- segments:
34
- - 2
35
- - 0
36
- version: "2.0"
37
- name: jeweler
38
- requirement: *id001
39
- prerelease: false
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
40
27
  type: :development
41
- - !ruby/object:Gem::Dependency
42
- version_requirements: &id002 !ruby/object:Gem::Requirement
28
+ prerelease: false
29
+ version_requirements: !ruby/object:Gem::Requirement
43
30
  none: false
44
- requirements:
31
+ requirements:
45
32
  - - ~>
46
- - !ruby/object:Gem::Version
47
- hash: 15
48
- segments:
49
- - 1
50
- - 0
51
- version: "1.0"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.0'
35
+ - !ruby/object:Gem::Dependency
52
36
  name: flexmock
53
- requirement: *id002
54
- prerelease: false
37
+ requirement: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '1.0'
55
43
  type: :development
56
- - !ruby/object:Gem::Dependency
57
- version_requirements: &id003 !ruby/object:Gem::Requirement
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
58
46
  none: false
59
- requirements:
47
+ requirements:
60
48
  - - ~>
61
- - !ruby/object:Gem::Version
62
- hash: 59
63
- segments:
64
- - 2
65
- - 13
66
- - 0
67
- version: 2.13.0
49
+ - !ruby/object:Gem::Version
50
+ version: '1.0'
51
+ - !ruby/object:Gem::Dependency
68
52
  name: rspec
69
- requirement: *id003
70
- prerelease: false
53
+ requirement: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: 2.13.0
71
59
  type: :development
72
- - !ruby/object:Gem::Dependency
73
- version_requirements: &id004 !ruby/object:Gem::Requirement
60
+ prerelease: false
61
+ version_requirements: !ruby/object:Gem::Requirement
74
62
  none: false
75
- requirements:
63
+ requirements:
76
64
  - - ~>
77
- - !ruby/object:Gem::Version
78
- hash: 15
79
- segments:
80
- - 1
81
- - 0
82
- version: "1.0"
65
+ - !ruby/object:Gem::Version
66
+ version: 2.13.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: cucumber
69
+ requirement: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
83
72
  - - <
84
- - !ruby/object:Gem::Version
85
- hash: 29
86
- segments:
87
- - 1
88
- - 3
89
- - 3
73
+ - !ruby/object:Gem::Version
90
74
  version: 1.3.3
91
- name: cucumber
92
- requirement: *id004
93
- prerelease: false
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
94
78
  type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - <
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.3
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: '1.0'
95
89
  description: A toolkit of useful, reusable foundation code created by RightScale.
96
90
  email: support@rightscale.com
97
91
  executables: []
98
-
99
92
  extensions: []
100
-
101
- extra_rdoc_files:
93
+ extra_rdoc_files:
102
94
  - LICENSE
103
95
  - README.rdoc
104
- files:
96
+ files:
105
97
  - .rspec
106
98
  - CHANGELOG.rdoc
107
99
  - Gemfile
@@ -220,39 +212,32 @@ files:
220
212
  - spec/stats/helpers_spec.rb
221
213
  - spec/validation/openssl_spec.rb
222
214
  - spec/validation/ssh_spec.rb
223
- has_rdoc: true
224
215
  homepage: https://github.com/rightscale/right_support
225
- licenses:
216
+ licenses:
226
217
  - MIT
227
218
  post_install_message:
228
219
  rdoc_options: []
229
-
230
- require_paths:
220
+ require_paths:
231
221
  - lib
232
- required_ruby_version: !ruby/object:Gem::Requirement
222
+ required_ruby_version: !ruby/object:Gem::Requirement
233
223
  none: false
234
- requirements:
235
- - - ">="
236
- - !ruby/object:Gem::Version
237
- hash: 3
238
- segments:
224
+ requirements:
225
+ - - ! '>='
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ segments:
239
229
  - 0
240
- version: "0"
241
- required_rubygems_version: !ruby/object:Gem::Requirement
230
+ hash: -4455262276770369018
231
+ required_rubygems_version: !ruby/object:Gem::Requirement
242
232
  none: false
243
- requirements:
244
- - - ">="
245
- - !ruby/object:Gem::Version
246
- hash: 3
247
- segments:
248
- - 0
249
- version: "0"
233
+ requirements:
234
+ - - ! '>='
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
250
237
  requirements: []
251
-
252
238
  rubyforge_project:
253
- rubygems_version: 1.3.7
239
+ rubygems_version: 1.8.26
254
240
  signing_key:
255
241
  specification_version: 3
256
242
  summary: Reusable foundation code.
257
243
  test_files: []
258
-