harness 0.9.0 → 0.9.1
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 +5 -1
- data/lib/harness/counter.rb +2 -4
- data/lib/harness/version.rb +1 -1
- data/test/integration/counters_with_redis_test.rb +8 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331d4b6080058b3d3691dbba570c2fd997a07d6b
|
4
|
+
data.tar.gz: 305a235a8ab89e07bd091dc381876ff9c4a7e656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1e3dbeeeafcdb43c21099b98ccda432c660b23d1f3cf130450a2c924d0894c527e5f66b94799c1e38d2025f3bc31b1ccf1638d667976b2c624805362b6f743
|
7
|
+
data.tar.gz: a6810d20de6134b3c1c43ff2aacec5d1e273248aaa6be557c771490f8c3da06fdd65f1cb5d6533683b0827378fc7891bee0c84bf74a60cbb7a035c897721ce87
|
data/lib/harness.rb
CHANGED
@@ -76,10 +76,14 @@ module Harness
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.reset_counters!
|
79
|
-
|
79
|
+
counters.each do |counter|
|
80
80
|
redis.set counter, 0
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
def self.counters
|
85
|
+
redis.keys "counters/*"
|
86
|
+
end
|
83
87
|
end
|
84
88
|
|
85
89
|
require 'harness/measurement'
|
data/lib/harness/counter.rb
CHANGED
@@ -13,16 +13,14 @@ module Harness
|
|
13
13
|
|
14
14
|
counter.id ||= event.name
|
15
15
|
|
16
|
-
Harness.redis.sadd 'counters', counter.id
|
17
|
-
|
18
16
|
if event.payload[:counter].is_a? Fixnum
|
19
17
|
counter.value = event.payload[:counter]
|
20
18
|
end
|
21
19
|
|
22
20
|
if counter.value
|
23
|
-
Harness.redis.set counter.id, counter.value
|
21
|
+
Harness.redis.set "counters/#{counter.id}", counter.value
|
24
22
|
else
|
25
|
-
counter.value = Harness.redis.incr(counter.id).to_i
|
23
|
+
counter.value = Harness.redis.incr("counters/#{counter.id}").to_i
|
26
24
|
end
|
27
25
|
|
28
26
|
counter
|
data/lib/harness/version.rb
CHANGED
@@ -4,8 +4,7 @@ class CountersWithRedis < IntegrationTest
|
|
4
4
|
def test_stores_name_in_redis
|
5
5
|
instrument "event-counter", :counter => true
|
6
6
|
|
7
|
-
|
8
|
-
assert_equal 1, redis.get('event-counter').to_i
|
7
|
+
assert_equal 1, redis.get('counters/event-counter').to_i
|
9
8
|
|
10
9
|
assert_counter_logged "event-counter"
|
11
10
|
end
|
@@ -13,9 +12,9 @@ class CountersWithRedis < IntegrationTest
|
|
13
12
|
def test_increments_counter_each_instrument
|
14
13
|
instrument "event-counter", :counter => true
|
15
14
|
assert_counter_logged "event-counter"
|
15
|
+
|
16
16
|
counters.clear
|
17
17
|
|
18
|
-
assert_empty counters
|
19
18
|
instrument "event-counter", :counter => true
|
20
19
|
assert_counter_logged "event-counter"
|
21
20
|
|
@@ -25,8 +24,6 @@ class CountersWithRedis < IntegrationTest
|
|
25
24
|
def test_sets_given_value_in_redis_with_shortform
|
26
25
|
instrument "event-counter", :counter => 10
|
27
26
|
|
28
|
-
assert_equal 10, redis.get("event-counter").to_i
|
29
|
-
|
30
27
|
counters.clear
|
31
28
|
|
32
29
|
instrument "event-counter", :counter => true
|
@@ -38,7 +35,7 @@ class CountersWithRedis < IntegrationTest
|
|
38
35
|
def test_sets_given_value_in_redis_with_longform
|
39
36
|
instrument "event-counter", :counter => { :value => 10 }
|
40
37
|
|
41
|
-
assert_equal 10, redis.get("event-counter").to_i
|
38
|
+
assert_equal 10, redis.get("counters/event-counter").to_i
|
42
39
|
|
43
40
|
counters.clear
|
44
41
|
|
@@ -52,29 +49,19 @@ class CountersWithRedis < IntegrationTest
|
|
52
49
|
instrument "event-counter", :counter => true
|
53
50
|
instrument "event-counter2", :counter => true
|
54
51
|
|
55
|
-
assert_equal 1, redis.get("event-counter").to_i
|
56
|
-
assert_equal 1, redis.get("event-counter2").to_i
|
52
|
+
assert_equal 1, redis.get("counters/event-counter").to_i
|
53
|
+
assert_equal 1, redis.get("counters/event-counter2").to_i
|
57
54
|
|
58
55
|
Harness.reset_counters!
|
59
56
|
|
60
|
-
assert_equal 0, redis.get("event-counter").to_i
|
61
|
-
assert_equal 0, redis.get("event-counter2").to_i
|
57
|
+
assert_equal 0, redis.get("counters/event-counter").to_i
|
58
|
+
assert_equal 0, redis.get("counters/event-counter2").to_i
|
62
59
|
|
63
60
|
counters.clear
|
64
61
|
instrument "event-counter", :counter => true
|
65
62
|
assert_counter_logged 'event-counter'
|
66
63
|
|
67
64
|
assert_equal 1, counters.first.value
|
68
|
-
assert_equal 1, redis.get("event-counter").to_i
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_resets_counters_resets_meters
|
72
|
-
instrument "event-counter", :counter => true
|
73
|
-
|
74
|
-
assert_equal 1, redis.get("event-counter").to_i
|
75
|
-
|
76
|
-
Harness.reset_counters!
|
77
|
-
|
78
|
-
assert_equal 0, redis.get("event-counter").to_i
|
65
|
+
assert_equal 1, redis.get("counters/event-counter").to_i
|
79
66
|
end
|
80
67
|
end
|