harness 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/harness.rb +0 -2
- data/lib/harness/counter.rb +0 -2
- data/lib/harness/version.rb +1 -1
- data/test/integration/counters_with_redis_test.rb +0 -8
- metadata +2 -5
- data/lib/harness/meter.rb +0 -55
- data/test/integration/meter_test.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b1ba669c00fddf944318514aaae8cc3184d43a
|
4
|
+
data.tar.gz: 7aab2e9ccd8d860dff8eab3ce29ed1aba54e8c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1b748e7ecbcf4a6c29da4b05835b60c1303865bacc4c0c6e9355399d25103e25624623394104a7b3f74f67b6f4ac264773dd4e1e5e30908b71056e381611914
|
7
|
+
data.tar.gz: 83bcf438c22c5a36a9b79cd1a4bb1449ab16dc11e698bff1ab85b6b82c6d9d04e31c82c23b08f9ad9b510846908ab5727272da1da66c5239b5634f474cc38f46
|
data/lib/harness.rb
CHANGED
@@ -78,7 +78,6 @@ module Harness
|
|
78
78
|
def self.reset_counters!
|
79
79
|
redis.smembers('counters').each do |counter|
|
80
80
|
redis.set counter, 0
|
81
|
-
redis.del "meters/#{counter}"
|
82
81
|
end
|
83
82
|
end
|
84
83
|
end
|
@@ -86,7 +85,6 @@ end
|
|
86
85
|
require 'harness/measurement'
|
87
86
|
require 'harness/counter'
|
88
87
|
require 'harness/gauge'
|
89
|
-
require 'harness/meter'
|
90
88
|
|
91
89
|
require 'harness/instrumentation'
|
92
90
|
|
data/lib/harness/counter.rb
CHANGED
data/lib/harness/version.rb
CHANGED
@@ -72,17 +72,9 @@ class CountersWithRedis < IntegrationTest
|
|
72
72
|
instrument "event-counter", :counter => true
|
73
73
|
|
74
74
|
assert_equal 1, redis.get("event-counter").to_i
|
75
|
-
assert_equal 1, redis.zcard("meters/event-counter").to_i
|
76
75
|
|
77
76
|
Harness.reset_counters!
|
78
77
|
|
79
78
|
assert_equal 0, redis.get("event-counter").to_i
|
80
|
-
assert_equal 0, redis.zcard("meters/event-counter").to_i
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_counting_updates_sorted_set_in_redis
|
84
|
-
instrument "event-counter", :counter => true
|
85
|
-
|
86
|
-
assert_equal 1, redis.zcard("meters/event-counter")
|
87
79
|
end
|
88
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ahawkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -226,7 +226,6 @@ files:
|
|
226
226
|
- lib/harness/integration/sidekiq.rb
|
227
227
|
- lib/harness/job.rb
|
228
228
|
- lib/harness/measurement.rb
|
229
|
-
- lib/harness/meter.rb
|
230
229
|
- lib/harness/queues/delayed_job_queue.rb
|
231
230
|
- lib/harness/queues/resque_queue.rb
|
232
231
|
- lib/harness/queues/sidekiq_queue.rb
|
@@ -243,7 +242,6 @@ files:
|
|
243
242
|
- test/integration/integrations/active_support_test.rb
|
244
243
|
- test/integration/integrations/sidekiq_test.rb
|
245
244
|
- test/integration/logging_test.rb
|
246
|
-
- test/integration/meter_test.rb
|
247
245
|
- test/integration/queues/delayed_job_test.rb
|
248
246
|
- test/integration/queues/resque_test.rb
|
249
247
|
- test/integration/queues/sidekiq_test.rb
|
@@ -290,7 +288,6 @@ test_files:
|
|
290
288
|
- test/integration/integrations/active_support_test.rb
|
291
289
|
- test/integration/integrations/sidekiq_test.rb
|
292
290
|
- test/integration/logging_test.rb
|
293
|
-
- test/integration/meter_test.rb
|
294
291
|
- test/integration/queues/delayed_job_test.rb
|
295
292
|
- test/integration/queues/resque_test.rb
|
296
293
|
- test/integration/queues/sidekiq_test.rb
|
data/lib/harness/meter.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module Harness
|
2
|
-
class Meter
|
3
|
-
def initialize(name)
|
4
|
-
@name = name
|
5
|
-
|
6
|
-
raise Harness::NoCounter, "#{@name} is not being metered" unless redis.exists key
|
7
|
-
end
|
8
|
-
|
9
|
-
def per_second
|
10
|
-
per 1.second
|
11
|
-
end
|
12
|
-
|
13
|
-
def per_minute
|
14
|
-
per 1.minute
|
15
|
-
end
|
16
|
-
|
17
|
-
def per_hour
|
18
|
-
per 1.hour
|
19
|
-
end
|
20
|
-
|
21
|
-
def per(rate, base = Time.now)
|
22
|
-
gauge = Gauge.new :value => redis.zcount(key, base.to_f - rate, base.to_f)
|
23
|
-
|
24
|
-
if words = rate_in_words(rate)
|
25
|
-
gauge.name = "#{@name} per #{words}"
|
26
|
-
gauge.id = "#{@name}-per-#{words}"
|
27
|
-
else
|
28
|
-
gauge.id = "#{@name} gauge"
|
29
|
-
end
|
30
|
-
|
31
|
-
gauge.time = Time.now
|
32
|
-
|
33
|
-
gauge
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def key
|
38
|
-
"meters/#{@name}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def redis
|
42
|
-
Harness.redis
|
43
|
-
end
|
44
|
-
|
45
|
-
def rate_in_words(rate)
|
46
|
-
if rate < 1.minute
|
47
|
-
"second"
|
48
|
-
elsif rate >= 1.minute && rate < 1.hour
|
49
|
-
"minute"
|
50
|
-
elsif rate >= 1.hour && rate < 1.day
|
51
|
-
"hour"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CountersWithRedis < IntegrationTest
|
4
|
-
def test_counters_can_act_like_gauges
|
5
|
-
50.times { instrument "event-counter", :counter => true }
|
6
|
-
|
7
|
-
meter = Harness::Meter.new 'event-counter'
|
8
|
-
assert_equal 50, meter.per_second.value
|
9
|
-
assert_equal 50, meter.per_minute.value
|
10
|
-
assert_equal 50, meter.per_hour.value
|
11
|
-
end
|
12
|
-
|
13
|
-
def tests_raises_an_error_when_no_such_counter
|
14
|
-
assert_raises Harness::NoCounter do
|
15
|
-
Harness::Meter.new 'unknown-counter'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_rates_return_gauges
|
20
|
-
50.times { instrument "event-counter", :counter => true }
|
21
|
-
|
22
|
-
meter = Harness::Meter.new 'event-counter'
|
23
|
-
|
24
|
-
gauge = meter.per_second
|
25
|
-
|
26
|
-
assert_kind_of Harness::Gauge, gauge
|
27
|
-
|
28
|
-
assert_equal "event-counter-per-second", gauge.id
|
29
|
-
assert_equal "event-counter per second", gauge.name
|
30
|
-
assert_kind_of Time, gauge.time
|
31
|
-
end
|
32
|
-
end
|