drone 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metadata +3 -41
- data/.gitignore +0 -8
- data/.rvmrc +0 -1
- data/.yardopts +0 -1
- data/Gemfile +0 -4
- data/LICENSE +0 -20
- data/README.md +0 -162
- data/Rakefile +0 -20
- data/drone.gemspec +0 -29
- data/examples/simple.rb +0 -50
- data/lib/drone.rb +0 -23
- data/lib/drone/core.rb +0 -141
- data/lib/drone/interfaces/base.rb +0 -17
- data/lib/drone/interfaces/console.rb +0 -82
- data/lib/drone/metrics/counter.rb +0 -40
- data/lib/drone/metrics/gauge.rb +0 -25
- data/lib/drone/metrics/histogram.rb +0 -153
- data/lib/drone/metrics/meter.rb +0 -82
- data/lib/drone/metrics/metric.rb +0 -16
- data/lib/drone/metrics/timer.rb +0 -57
- data/lib/drone/monitoring.rb +0 -107
- data/lib/drone/schedulers/eventmachine.rb +0 -70
- data/lib/drone/storage/base.rb +0 -122
- data/lib/drone/storage/memory.rb +0 -58
- data/lib/drone/utils/ewma.rb +0 -55
- data/lib/drone/utils/exponentially_decaying_sample.rb +0 -81
- data/lib/drone/utils/uniform_sample.rb +0 -52
- data/lib/drone/version.rb +0 -3
- data/specs/all.rb +0 -11
- data/specs/common.rb +0 -63
- data/specs/metrics/counter_spec.rb +0 -43
- data/specs/metrics/gauge_spec.rb +0 -28
- data/specs/metrics/meter_spec.rb +0 -61
- data/specs/metrics/timer_spec.rb +0 -111
- data/specs/schedulers/eventmachine_spec.rb +0 -76
- data/specs/unit/ewma_spec.rb +0 -141
- data/specs/unit/exponentially_decaying_sample_spec.rb +0 -86
- data/specs/unit/histogram_spec.rb +0 -91
- data/specs/unit/monitoring_spec.rb +0 -129
- data/specs/unit/uniform_sample_spec.rb +0 -46
@@ -1,52 +0,0 @@
|
|
1
|
-
require File.expand_path('../../core', __FILE__)
|
2
|
-
|
3
|
-
module Drone
|
4
|
-
class UniformSample
|
5
|
-
|
6
|
-
##
|
7
|
-
# Create a new instance.
|
8
|
-
#
|
9
|
-
# @param [String] id A string which will be used by distributed
|
10
|
-
# storage backend to use the same value for all instances with
|
11
|
-
# the same id
|
12
|
-
# @param [Number] size The size of the requested array
|
13
|
-
#
|
14
|
-
def initialize(id, size)
|
15
|
-
@id = id
|
16
|
-
@values = Drone::request_fixed_size_array("#{id}:values", size, 0)
|
17
|
-
@count = Drone::request_number("#{id}:count", 0)
|
18
|
-
end
|
19
|
-
|
20
|
-
# def clear
|
21
|
-
# @values.size.times do |n|
|
22
|
-
# @values[n] = 0
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# @count.set(0)
|
26
|
-
# end
|
27
|
-
|
28
|
-
def size
|
29
|
-
c = @count.get
|
30
|
-
(c > @values.size) ? @values.size : c
|
31
|
-
end
|
32
|
-
|
33
|
-
def update(val)
|
34
|
-
@count.inc
|
35
|
-
count = @count.get
|
36
|
-
if count <= @values.size
|
37
|
-
@values[count - 1] = val
|
38
|
-
else
|
39
|
-
r = rand(2**64 - 1) % count
|
40
|
-
if r < @values.size
|
41
|
-
@values[r] = val
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def values
|
47
|
-
# only return @count elements
|
48
|
-
@values[0,@count.get]
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
data/lib/drone/version.rb
DELETED
data/specs/all.rb
DELETED
data/specs/common.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
$:.reject! { |e| e.include? 'TextMate' }
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
|
5
|
-
puts "Testing with ruby #{RUBY_VERSION} and rubygems #{Gem::VERSION}"
|
6
|
-
|
7
|
-
if (RUBY_VERSION >= "1.9") && ENV['COVERAGE']
|
8
|
-
require 'simplecov'
|
9
|
-
ROOT = File.expand_path('../../', __FILE__)
|
10
|
-
|
11
|
-
puts "[[ SimpleCov enabled ]]"
|
12
|
-
|
13
|
-
SimpleCov.start do
|
14
|
-
add_filter '/gems/'
|
15
|
-
add_filter '/specs/'
|
16
|
-
|
17
|
-
root(ROOT)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'bundler/setup'
|
22
|
-
|
23
|
-
require 'bacon'
|
24
|
-
require 'mocha'
|
25
|
-
require 'delorean'
|
26
|
-
require 'em-spec/bacon'
|
27
|
-
EM.spec_backend = EventMachine::Spec::Bacon
|
28
|
-
|
29
|
-
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
30
|
-
|
31
|
-
module Bacon
|
32
|
-
module MochaRequirementsCounter
|
33
|
-
def self.increment
|
34
|
-
Counter[:requirements] += 1
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class Context
|
39
|
-
include Mocha::API
|
40
|
-
|
41
|
-
alias_method :it_before_mocha, :it
|
42
|
-
|
43
|
-
def it(description)
|
44
|
-
it_before_mocha(description) do
|
45
|
-
begin
|
46
|
-
mocha_setup
|
47
|
-
yield
|
48
|
-
mocha_verify(MochaRequirementsCounter)
|
49
|
-
rescue Mocha::ExpectationError => e
|
50
|
-
raise Error.new(:failed, "#{e.message}\n#{e.backtrace[0...10].join("\n")}")
|
51
|
-
ensure
|
52
|
-
mocha_teardown
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def focus(test_label)
|
60
|
-
Bacon.const_set(:RestrictName, %r{#{test_label}})
|
61
|
-
end
|
62
|
-
|
63
|
-
Bacon.summary_on_exit()
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.expand_path('../../common', __FILE__)
|
2
|
-
|
3
|
-
require 'drone/core'
|
4
|
-
require 'drone/metrics/counter'
|
5
|
-
include Drone
|
6
|
-
|
7
|
-
describe 'Counter Metrics' do
|
8
|
-
before do
|
9
|
-
Drone::init_drone()
|
10
|
-
@counter = Metrics::Counter.new('something')
|
11
|
-
end
|
12
|
-
|
13
|
-
should "start at zero" do
|
14
|
-
@counter.value.should == 0
|
15
|
-
end
|
16
|
-
|
17
|
-
should "increment by one" do
|
18
|
-
@counter.inc()
|
19
|
-
@counter.value.should == 1
|
20
|
-
end
|
21
|
-
|
22
|
-
should "increment by an arbitrary delta" do
|
23
|
-
@counter.inc(3)
|
24
|
-
@counter.value.should == 3
|
25
|
-
end
|
26
|
-
|
27
|
-
should "decrement by one" do
|
28
|
-
@counter.dec()
|
29
|
-
@counter.value.should == -1
|
30
|
-
end
|
31
|
-
|
32
|
-
should "decrement by an arbitrary delta" do
|
33
|
-
@counter.dec(3)
|
34
|
-
@counter.value.should == -3
|
35
|
-
end
|
36
|
-
|
37
|
-
should "be zero after being cleared" do
|
38
|
-
@counter.inc(3)
|
39
|
-
@counter.clear()
|
40
|
-
@counter.value.should == 0
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/specs/metrics/gauge_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require File.expand_path('../../common', __FILE__)
|
2
|
-
|
3
|
-
require 'drone/metrics/gauge'
|
4
|
-
include Drone
|
5
|
-
|
6
|
-
describe 'Geuge Metric' do
|
7
|
-
before do
|
8
|
-
@n = 0
|
9
|
-
@gauge = Metrics::Gauge.new("temperature"){ @n+= 1 }
|
10
|
-
end
|
11
|
-
|
12
|
-
should 'require a block' do
|
13
|
-
err = proc{
|
14
|
-
Metrics::Gauge.new('dummy')
|
15
|
-
}.should.raise(RuntimeError)
|
16
|
-
|
17
|
-
err.message.should.include?('Block expected')
|
18
|
-
end
|
19
|
-
|
20
|
-
should 'call block when value is asked' do
|
21
|
-
@n.should == 0
|
22
|
-
@gauge.value.should == 1
|
23
|
-
@n.should == 1
|
24
|
-
|
25
|
-
@gauge.value.should == 2
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
data/specs/metrics/meter_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require File.expand_path('../../common', __FILE__)
|
2
|
-
|
3
|
-
require 'drone/metrics/meter'
|
4
|
-
|
5
|
-
include Drone
|
6
|
-
|
7
|
-
EM.describe 'Meter Metrics' do
|
8
|
-
before do
|
9
|
-
Drone::init_drone()
|
10
|
-
Drone::start_monitoring()
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "A meter metric with no events" do
|
14
|
-
before do
|
15
|
-
@meter = Metrics::Meter.new("thangs")
|
16
|
-
end
|
17
|
-
|
18
|
-
should "have a count of zero" do
|
19
|
-
@meter.count.should == 0
|
20
|
-
done
|
21
|
-
end
|
22
|
-
|
23
|
-
should "have a mean rate of 0 events/sec" do
|
24
|
-
@meter.mean_rate.should == 0.0
|
25
|
-
done
|
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
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "A meter metric with three events" do
|
50
|
-
before do
|
51
|
-
@meter = Metrics::Meter.new("thangs")
|
52
|
-
@meter.mark(3)
|
53
|
-
end
|
54
|
-
|
55
|
-
should "have a count of three" do
|
56
|
-
@meter.count.should == 3
|
57
|
-
done
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
data/specs/metrics/timer_spec.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
require File.expand_path('../../common', __FILE__)
|
2
|
-
|
3
|
-
require 'drone/metrics/timer'
|
4
|
-
include Drone
|
5
|
-
|
6
|
-
EM.describe 'Timer Metrics' do
|
7
|
-
before do
|
8
|
-
Drone::init_drone()
|
9
|
-
Drone::start_monitoring()
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "A blank timer" do
|
13
|
-
before do
|
14
|
-
@timer = Metrics::Timer.new('id')
|
15
|
-
end
|
16
|
-
|
17
|
-
should "have a max of zero" do
|
18
|
-
@timer.max.should.be.close?(0, 0.001)
|
19
|
-
done
|
20
|
-
end
|
21
|
-
|
22
|
-
should "have a min of zero" do
|
23
|
-
@timer.min.should.be.close?(0, 0.001)
|
24
|
-
done
|
25
|
-
end
|
26
|
-
|
27
|
-
should "have a mean of zero" do
|
28
|
-
@timer.mean.should.be.close?(0, 0.001)
|
29
|
-
done
|
30
|
-
end
|
31
|
-
|
32
|
-
should "have a count of zero" do
|
33
|
-
@timer.count.should == 0
|
34
|
-
done
|
35
|
-
end
|
36
|
-
|
37
|
-
should "have a standard deviation of zero" do
|
38
|
-
@timer.stdDev.should.be.close?(0, 0.001)
|
39
|
-
done
|
40
|
-
end
|
41
|
-
|
42
|
-
should "have a median/p95/p98/p99/p999 of zero" do
|
43
|
-
median, p95, p98, p99, p999 = @timer.percentiles(0.5, 0.95, 0.98, 0.99, 0.999)
|
44
|
-
median.should.be.close?(0, 0.001)
|
45
|
-
p95.should.be.close?(0, 0.001)
|
46
|
-
p98.should.be.close?(0, 0.001)
|
47
|
-
p99.should.be.close?(0, 0.001)
|
48
|
-
p999.should.be.close?(0, 0.001)
|
49
|
-
done
|
50
|
-
end
|
51
|
-
|
52
|
-
should "have no values" do
|
53
|
-
@timer.values.should == []
|
54
|
-
done
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
describe "Timing a series of events" do
|
61
|
-
before do
|
62
|
-
@timer = Metrics::Timer.new('id')
|
63
|
-
@timer.update(10)
|
64
|
-
@timer.update(20)
|
65
|
-
@timer.update(20)
|
66
|
-
@timer.update(30)
|
67
|
-
@timer.update(40)
|
68
|
-
end
|
69
|
-
|
70
|
-
should "record the count" do
|
71
|
-
@timer.count.should == 5
|
72
|
-
done
|
73
|
-
end
|
74
|
-
|
75
|
-
should "calculate the minimum duration" do
|
76
|
-
@timer.min.should.be.close?(10, 0.001)
|
77
|
-
done
|
78
|
-
end
|
79
|
-
|
80
|
-
should "calclate the maximum duration" do
|
81
|
-
@timer.max.should.be.close?(40, 0.001)
|
82
|
-
done
|
83
|
-
end
|
84
|
-
|
85
|
-
should "calclate the mean duration" do
|
86
|
-
@timer.mean.should.be.close?(24, 0.001)
|
87
|
-
done
|
88
|
-
end
|
89
|
-
|
90
|
-
should "calclate the standard deviation" do
|
91
|
-
@timer.stdDev.should.be.close?(11.401, 0.001)
|
92
|
-
done
|
93
|
-
end
|
94
|
-
|
95
|
-
should "calculate the median/p95/p98/p99/p999" do
|
96
|
-
median, p95, p98, p99, p999 = @timer.percentiles(0.5, 0.95, 0.98, 0.99, 0.999)
|
97
|
-
median.should.be.close?(20, 0.001)
|
98
|
-
p95.should.be.close?(40, 0.001)
|
99
|
-
p98.should.be.close?(40, 0.001)
|
100
|
-
p99.should.be.close?(40, 0.001)
|
101
|
-
p999.should.be.close?(40, 0.001)
|
102
|
-
done
|
103
|
-
end
|
104
|
-
|
105
|
-
should "have a series of values" do
|
106
|
-
@timer.values.sort.should == [10, 20, 20, 30, 40]
|
107
|
-
done
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require File.expand_path('../../common', __FILE__)
|
2
|
-
|
3
|
-
require 'drone/schedulers/eventmachine'
|
4
|
-
|
5
|
-
describe 'Eventmachine Scheduler' do
|
6
|
-
|
7
|
-
describe 'in waiting state' do
|
8
|
-
before do
|
9
|
-
@scheduler = Drone::Schedulers::EMScheduler
|
10
|
-
class << @scheduler
|
11
|
-
def timers_periodic; @timers_periodic; end
|
12
|
-
def timers_once; @timers_once; end
|
13
|
-
end
|
14
|
-
|
15
|
-
EM::reactor_running?.should == false
|
16
|
-
|
17
|
-
@scheduler.reset()
|
18
|
-
end
|
19
|
-
|
20
|
-
should "enqueue timers" do
|
21
|
-
n = 0
|
22
|
-
@scheduler.schedule_once(1){ n = 10 }
|
23
|
-
n.should == 0
|
24
|
-
@scheduler.timers_once.size.should == 1
|
25
|
-
end
|
26
|
-
|
27
|
-
should "enqueue periodic timers" do
|
28
|
-
n = 0
|
29
|
-
@scheduler.schedule_periodic(1){ n = 10 }
|
30
|
-
n.should == 0
|
31
|
-
@scheduler.timers_periodic.size.should == 1
|
32
|
-
end
|
33
|
-
|
34
|
-
should "start timers when started" do
|
35
|
-
EM::expects(:add_periodic_timer).once.with(12)
|
36
|
-
@scheduler.schedule_periodic(12){ }
|
37
|
-
|
38
|
-
EM.expects(:add_timer).once.with(1)
|
39
|
-
@scheduler.schedule_once(1){ }
|
40
|
-
|
41
|
-
@scheduler.timers_periodic.size.should == 1
|
42
|
-
@scheduler.timers_once.size.should == 1
|
43
|
-
|
44
|
-
@scheduler.start
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
EM.describe 'in started state' do
|
51
|
-
before do
|
52
|
-
@scheduler = Drone::Schedulers::EMScheduler
|
53
|
-
@scheduler.reset()
|
54
|
-
EM::reactor_running?.should == true
|
55
|
-
@scheduler.start()
|
56
|
-
end
|
57
|
-
|
58
|
-
should 'start a timer when a job is scheduled' do
|
59
|
-
EM::expects(:add_timer).with(23)
|
60
|
-
@scheduler.schedule_once(23){}
|
61
|
-
done
|
62
|
-
end
|
63
|
-
|
64
|
-
should 'start run the job and start a periodic timer when a periodic job is scheduled' do
|
65
|
-
n = 0
|
66
|
-
proc = lambda do
|
67
|
-
n+= 1
|
68
|
-
done if n == 2
|
69
|
-
end
|
70
|
-
|
71
|
-
@scheduler.schedule_periodic(0.001, &proc)
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|