drone 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/drone/interfaces/console.rb +0 -1
- data/lib/drone/metrics/timer.rb +3 -15
- data/lib/drone/version.rb +1 -1
- data/specs/all.rb +11 -0
- data/specs/metrics/meter_spec.rb +21 -0
- data/specs/metrics/timer_spec.rb +0 -20
- metadata +3 -2
data/lib/drone/metrics/timer.rb
CHANGED
@@ -5,9 +5,11 @@ require File.expand_path('..//meter', __FILE__)
|
|
5
5
|
module Drone
|
6
6
|
module Metrics
|
7
7
|
class Timer
|
8
|
+
attr_reader :name
|
9
|
+
|
8
10
|
def initialize(name = 'calls')
|
11
|
+
@name = name
|
9
12
|
@histogram = Histogram.new(Histogram::TYPE_BIASED)
|
10
|
-
@meter = Meter.new(name)
|
11
13
|
clear()
|
12
14
|
end
|
13
15
|
|
@@ -15,12 +17,6 @@ module Drone
|
|
15
17
|
@histogram.count
|
16
18
|
end
|
17
19
|
|
18
|
-
[:fifteen_minutes_rate, :five_minutes_rate, :mean_rate, :one_minute_rate].each do |attr_name|
|
19
|
-
define_method(attr_name) do
|
20
|
-
@meter.send(attr_name)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
20
|
# may requires a conversion... or not
|
25
21
|
[:count, :min, :max, :mean, :stdDev, :percentiles, :values].each do |attr_name|
|
26
22
|
define_method(attr_name) do |*args|
|
@@ -37,7 +33,6 @@ module Drone
|
|
37
33
|
def update(duration)
|
38
34
|
if duration >= 0
|
39
35
|
@histogram.update(duration)
|
40
|
-
@meter.mark()
|
41
36
|
end
|
42
37
|
end
|
43
38
|
|
@@ -50,13 +45,6 @@ module Drone
|
|
50
45
|
update(Time.now.to_f - started_at.to_f)
|
51
46
|
end
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def name
|
57
|
-
@meter.name
|
58
|
-
end
|
59
|
-
|
60
48
|
end
|
61
49
|
end
|
62
50
|
end
|
data/lib/drone/version.rb
CHANGED
data/specs/all.rb
ADDED
data/specs/metrics/meter_spec.rb
CHANGED
@@ -7,6 +7,7 @@ include Drone
|
|
7
7
|
EM.describe 'Meter Metrics' do
|
8
8
|
before do
|
9
9
|
Drone::init_drone()
|
10
|
+
Drone::start_monitoring()
|
10
11
|
end
|
11
12
|
|
12
13
|
describe "A meter metric with no events" do
|
@@ -23,6 +24,26 @@ EM.describe 'Meter Metrics' do
|
|
23
24
|
@meter.mean_rate.should == 0.0
|
24
25
|
done
|
25
26
|
end
|
27
|
+
|
28
|
+
should "have a mean rate of zero" do
|
29
|
+
@meter.mean_rate.should.be.close?(0, 0.001)
|
30
|
+
done
|
31
|
+
end
|
32
|
+
|
33
|
+
should "have a one-minute rate of zero" do
|
34
|
+
@meter.one_minute_rate.should.be.close?(0, 0.001)
|
35
|
+
done
|
36
|
+
end
|
37
|
+
|
38
|
+
should "have a five-minute rate of zero" do
|
39
|
+
@meter.five_minutes_rate.should.be.close?(0, 0.001)
|
40
|
+
done
|
41
|
+
end
|
42
|
+
|
43
|
+
should "have a fifteen-minute rate of zero" do
|
44
|
+
@meter.fifteen_minutes_rate.should.be.close?(0, 0.001)
|
45
|
+
done
|
46
|
+
end
|
26
47
|
end
|
27
48
|
|
28
49
|
describe "A meter metric with three events" do
|
data/specs/metrics/timer_spec.rb
CHANGED
@@ -48,26 +48,6 @@ EM.describe 'Timer Metrics' do
|
|
48
48
|
p999.should.be.close?(0, 0.001)
|
49
49
|
done
|
50
50
|
end
|
51
|
-
|
52
|
-
should "have a mean rate of zero" do
|
53
|
-
@timer.mean_rate.should.be.close?(0, 0.001)
|
54
|
-
done
|
55
|
-
end
|
56
|
-
|
57
|
-
should "have a one-minute rate of zero" do
|
58
|
-
@timer.one_minute_rate.should.be.close?(0, 0.001)
|
59
|
-
done
|
60
|
-
end
|
61
|
-
|
62
|
-
should "have a five-minute rate of zero" do
|
63
|
-
@timer.five_minutes_rate.should.be.close?(0, 0.001)
|
64
|
-
done
|
65
|
-
end
|
66
|
-
|
67
|
-
should "have a fifteen-minute rate of zero" do
|
68
|
-
@timer.fifteen_minutes_rate.should.be.close?(0, 0.001)
|
69
|
-
done
|
70
|
-
end
|
71
51
|
|
72
52
|
should "have no values" do
|
73
53
|
@timer.values.should == []
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: drone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Julien Ammous
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-19 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/drone/utils/exponentially_decaying_sample.rb
|
113
113
|
- lib/drone/utils/uniform_sample.rb
|
114
114
|
- lib/drone/version.rb
|
115
|
+
- specs/all.rb
|
115
116
|
- specs/common.rb
|
116
117
|
- specs/metrics/counter_spec.rb
|
117
118
|
- specs/metrics/gauge_spec.rb
|