pulse-meter 0.2.11 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rbenv-version +1 -1
- data/README.md +32 -16
- data/Rakefile +29 -10
- data/examples/basic.ru +1 -1
- data/examples/full/server.ru +1 -1
- data/examples/minimal/server.ru +1 -1
- data/lib/pulse-meter.rb +1 -0
- data/lib/pulse-meter/observer.rb +117 -0
- data/lib/pulse-meter/sensor.rb +1 -0
- data/lib/pulse-meter/sensor/timeline.rb +3 -2
- data/lib/pulse-meter/sensor/timelined/multi_percentile.rb +43 -0
- data/lib/pulse-meter/version.rb +1 -1
- data/lib/pulse-meter/visualize/app.rb +28 -12
- data/lib/pulse-meter/visualize/coffee/application.coffee +40 -0
- data/lib/pulse-meter/visualize/coffee/collections/page_info_list.coffee +17 -0
- data/lib/pulse-meter/visualize/coffee/collections/sensor_info_list.coffee +4 -0
- data/lib/pulse-meter/visualize/coffee/collections/widget_list.coffee +14 -0
- data/lib/pulse-meter/visualize/coffee/extensions.coffee +26 -0
- data/lib/pulse-meter/visualize/coffee/models/dinamic_widget.coffee +34 -0
- data/lib/pulse-meter/visualize/coffee/models/page_info.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/models/sensor_info.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/models/widget.coffee +54 -0
- data/lib/pulse-meter/visualize/coffee/presenters/area.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/presenters/gauge.coffee +11 -0
- data/lib/pulse-meter/visualize/coffee/presenters/line.coffee +2 -0
- data/lib/pulse-meter/visualize/coffee/presenters/pie.coffee +20 -0
- data/lib/pulse-meter/visualize/coffee/presenters/series.coffee +44 -0
- data/lib/pulse-meter/visualize/coffee/presenters/table.coffee +10 -0
- data/lib/pulse-meter/visualize/coffee/presenters/timeline.coffee +13 -0
- data/lib/pulse-meter/visualize/coffee/presenters/widget.coffee +65 -0
- data/lib/pulse-meter/visualize/coffee/router.coffee +21 -0
- data/lib/pulse-meter/visualize/coffee/views/dynamic_chart.coffee +91 -0
- data/lib/pulse-meter/visualize/coffee/views/dynamic_widget.coffee +58 -0
- data/lib/pulse-meter/visualize/coffee/views/page_title.coffee +17 -0
- data/lib/pulse-meter/visualize/coffee/views/page_titles.coffee +15 -0
- data/lib/pulse-meter/visualize/coffee/views/sensor_info_list.coffee +19 -0
- data/lib/pulse-meter/visualize/coffee/views/widget.coffee +99 -0
- data/lib/pulse-meter/visualize/coffee/views/widget_chart.coffee +13 -0
- data/lib/pulse-meter/visualize/coffee/views/widget_list.coffee +15 -0
- data/lib/pulse-meter/visualize/layout.rb +4 -4
- data/lib/pulse-meter/visualize/public/css/application.css +13 -4
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_222222_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_454545_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_888888_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_f6cf3b_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/jquery-ui-1.8.16.bootstrap.css +1320 -0
- data/lib/pulse-meter/visualize/public/js/application.js +900 -691
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.16.bootstrap.min.js +791 -0
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.23.custom.min.js +21 -0
- data/lib/pulse-meter/visualize/public/js/jquery-ui-timepicker-addon.js +1687 -0
- data/lib/pulse-meter/visualize/sensor.rb +2 -2
- data/lib/pulse-meter/visualize/views/main.haml +2 -3
- data/lib/pulse-meter/visualize/views/sensors.haml +14 -1
- data/lib/pulse-meter/visualize/views/widgets/area.haml +46 -24
- data/lib/pulse-meter/visualize/views/widgets/line.haml +46 -23
- data/lib/pulse-meter/visualize/views/widgets/table.haml +37 -15
- data/lib/pulse-meter/visualize/widgets/timeline.rb +20 -5
- data/pulse-meter.gemspec +4 -0
- data/spec/pulse_meter/observer_spec.rb +252 -0
- data/spec/pulse_meter/sensor/timelined/multi_percentile_spec.rb +21 -0
- data/spec/pulse_meter/visualize/sensor_spec.rb +5 -5
- data/spec/pulse_meter/visualize/widgets/area_spec.rb +1 -74
- data/spec/pulse_meter/visualize/widgets/line_spec.rb +1 -73
- data/spec/pulse_meter/visualize/widgets/table_spec.rb +1 -73
- data/spec/shared_examples/timeline_sensor.rb +10 -0
- data/spec/shared_examples/widget.rb +97 -0
- data/spec/spec_helper.rb +1 -0
- metadata +120 -5
- data/lib/pulse-meter/visualize/public/js/application.coffee +0 -616
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PulseMeter::Sensor::Timelined::MultiPercentile do
|
4
|
+
it_should_behave_like "timeline sensor", {:p => [0.8]}
|
5
|
+
it_should_behave_like "timelined subclass", [5, 4, 2, 2, 2, 2, 2, 2, 2, 1], {0.8 => 2, 0.5 => 2}.to_json, {:p => [0.8, 0.5]}
|
6
|
+
it_should_behave_like "timelined subclass", [1], {0.8 => 1}.to_json, {:p => [0.8]}
|
7
|
+
|
8
|
+
let(:init_values) {{:ttl => 1, :raw_data_ttl => 1, :interval => 1, :reduce_delay => 1}}
|
9
|
+
let(:name) {"percentile"}
|
10
|
+
|
11
|
+
it "should raise exception when extra parameter is not array of percentiles" do
|
12
|
+
expect {described_class.new(name, init_values.merge({:p => :bad}))}.to raise_exception(ArgumentError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise exception when one of percentiles is not between 0 and 1" do
|
16
|
+
expect {described_class.new(name, init_values.merge({:p => [0.5, -1]}))}.to raise_exception(ArgumentError)
|
17
|
+
expect {described_class.new(name, init_values.merge({:p => [0.5, 1.1]}))}.to raise_exception(ArgumentError)
|
18
|
+
expect {described_class.new(name, init_values.merge({:p => [0.5, 0.1]}))}.not_to raise_exception(ArgumentError)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -89,7 +89,7 @@ describe PulseMeter::Visualize::Sensor do
|
|
89
89
|
|
90
90
|
context "when sensor does not exist" do
|
91
91
|
it "should raise RestoreError" do
|
92
|
-
expect{ bad_sensor.timeline_data(Time.now,
|
92
|
+
expect{ bad_sensor.timeline_data(Time.now - interval, Time.now) }.to raise_exception(PulseMeter::RestoreError)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -97,20 +97,20 @@ describe PulseMeter::Visualize::Sensor do
|
|
97
97
|
describe "returned value" do
|
98
98
|
it "should contain sensor annotation" do
|
99
99
|
Timecop.freeze(interval_start + interval + 1) do
|
100
|
-
sensor.timeline_data(Time.now,
|
100
|
+
sensor.timeline_data(Time.now - interval, Time.now).first[:name].should == annotation
|
101
101
|
end
|
102
102
|
end
|
103
103
|
it "should contain sensor color" do
|
104
104
|
Timecop.freeze(interval_start + interval + 1) do
|
105
|
-
sensor_with_color.timeline_data(Time.now,
|
105
|
+
sensor_with_color.timeline_data(Time.now - interval, Time.now).first[:color].should == color
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should contain [interval_start, value] pairs for each interval" do
|
110
110
|
Timecop.freeze(interval_start + interval + 1) do
|
111
|
-
data = sensor.timeline_data(Time.now
|
111
|
+
data = sensor.timeline_data(Time.now - interval * 2, Time.now)
|
112
112
|
data.first[:data].should == [{x: interval_start.to_i * 1000, y: 101}]
|
113
|
-
data = sensor.timeline_data(Time.now
|
113
|
+
data = sensor.timeline_data(Time.now - interval * 2, Time.now, true)
|
114
114
|
data.first[:data].should == [{x: interval_start.to_i * 1000, y: 101}, {x: (interval_start + interval).to_i * 1000, y: 55}]
|
115
115
|
end
|
116
116
|
end
|
@@ -1,79 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe PulseMeter::Visualize::Widgets::Area do
|
4
|
-
|
5
|
-
let!(:a_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:a_sensor, :ttl => 1000, :interval => interval, annotation: 'A') }
|
6
|
-
let!(:b_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:b_sensor, :ttl => 1000, :interval => interval, annotation: 'B') }
|
7
|
-
|
8
|
-
let(:widget_name){ "some_widget" }
|
9
|
-
|
10
|
-
let(:redraw_interval){5}
|
11
|
-
let(:values_label){'xxxx'}
|
12
|
-
let(:width){6}
|
13
|
-
let(:timespan){interval * 2}
|
14
|
-
let(:a_color){'#FF0000'}
|
15
|
-
let(:b_color){'#FFFF00'}
|
16
|
-
|
17
|
-
let(:interval_start){ Time.at((Time.now.to_i / interval) * interval) }
|
18
|
-
|
19
|
-
let(:widget) do
|
20
|
-
w = PulseMeter::Visualize::DSL::Widgets::Area.new(widget_name)
|
21
|
-
w.redraw_interval redraw_interval
|
22
|
-
w.width width
|
23
|
-
w.sensor :a_sensor, color: a_color
|
24
|
-
w.sensor :b_sensor, color: b_color
|
25
|
-
w.gchart_options a: 1
|
26
|
-
w.timespan timespan
|
27
|
-
w.to_data
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#data" do
|
31
|
-
it "should contain type, title, redraw_interval, width, gchart_options, timespan attriutes" do
|
32
|
-
wdata = widget.data
|
33
|
-
wdata[:type].should == 'area'
|
34
|
-
wdata[:title].should == widget_name
|
35
|
-
wdata[:redraw_interval].should == redraw_interval
|
36
|
-
wdata[:width].should == width
|
37
|
-
wdata[:gchart_options].should == {a: 1}
|
38
|
-
wdata[:timespan].should == timespan
|
39
|
-
wdata[:interval].should == interval
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "series attribute" do
|
43
|
-
before(:each) do
|
44
|
-
Timecop.freeze(interval_start + 1) do
|
45
|
-
a_sensor.event(12)
|
46
|
-
b_sensor.event(33)
|
47
|
-
end
|
48
|
-
Timecop.freeze(interval_start + interval + 1) do
|
49
|
-
a_sensor.event(111)
|
50
|
-
end
|
51
|
-
@current_time = interval_start + 2 * interval - 1
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should contain valid series" do
|
55
|
-
Timecop.freeze(@current_time) do
|
56
|
-
widget.data[:series].should ==
|
57
|
-
{
|
58
|
-
titles: [a_sensor.annotation, b_sensor.annotation],
|
59
|
-
rows: [[interval_start.to_i * 1000, 12, 33]],
|
60
|
-
options: [
|
61
|
-
{color: a_color},
|
62
|
-
{color: b_color}
|
63
|
-
]
|
64
|
-
}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should accept custom timespan" do
|
69
|
-
Timecop.freeze(@current_time + interval) do
|
70
|
-
widget.data(timespan: timespan)[:series][:rows].size.should == 1
|
71
|
-
widget.data(timespan: timespan + interval)[:series][:rows].size.should == 2
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
4
|
+
it_should_behave_like "widget"
|
77
5
|
end
|
78
6
|
|
79
|
-
|
@@ -1,78 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe PulseMeter::Visualize::Widgets::Line do
|
4
|
-
|
5
|
-
let!(:a_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:a_sensor, :ttl => 1000, :interval => interval, annotation: 'A') }
|
6
|
-
let!(:b_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:b_sensor, :ttl => 1000, :interval => interval, annotation: 'B') }
|
7
|
-
|
8
|
-
let(:widget_name){ "some_widget" }
|
9
|
-
|
10
|
-
let(:redraw_interval){5}
|
11
|
-
let(:values_label){'xxxx'}
|
12
|
-
let(:width){6}
|
13
|
-
let(:timespan){interval * 2}
|
14
|
-
let(:a_color){'#FF0000'}
|
15
|
-
let(:b_color){'#FFFF00'}
|
16
|
-
|
17
|
-
let(:interval_start){ Time.at((Time.now.to_i / interval) * interval) }
|
18
|
-
|
19
|
-
let(:widget) do
|
20
|
-
w = PulseMeter::Visualize::DSL::Widgets::Line.new(widget_name)
|
21
|
-
w.redraw_interval redraw_interval
|
22
|
-
w.width width
|
23
|
-
w.sensor :a_sensor, color: a_color
|
24
|
-
w.sensor :b_sensor, color: b_color
|
25
|
-
w.gchart_options a: 1
|
26
|
-
w.timespan timespan
|
27
|
-
w.to_data
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#data" do
|
31
|
-
it "should contain type, title, redraw_interval, width, gchart_options, timespan attriutes" do
|
32
|
-
wdata = widget.data
|
33
|
-
wdata[:type].should == 'line'
|
34
|
-
wdata[:title].should == widget_name
|
35
|
-
wdata[:redraw_interval].should == redraw_interval
|
36
|
-
wdata[:width].should == width
|
37
|
-
wdata[:gchart_options].should == {a: 1}
|
38
|
-
wdata[:timespan].should == timespan
|
39
|
-
wdata[:interval].should == interval
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "series attribute" do
|
43
|
-
before(:each) do
|
44
|
-
Timecop.freeze(interval_start + 1) do
|
45
|
-
a_sensor.event(12)
|
46
|
-
b_sensor.event(33)
|
47
|
-
end
|
48
|
-
Timecop.freeze(interval_start + interval + 1) do
|
49
|
-
a_sensor.event(111)
|
50
|
-
end
|
51
|
-
@current_time = interval_start + 2 * interval - 1
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should contain valid series" do
|
55
|
-
Timecop.freeze(@current_time) do
|
56
|
-
widget.data[:series].should ==
|
57
|
-
{
|
58
|
-
titles: [a_sensor.annotation, b_sensor.annotation],
|
59
|
-
rows: [[interval_start.to_i * 1000, 12, 33]],
|
60
|
-
options: [
|
61
|
-
{color: a_color},
|
62
|
-
{color: b_color}
|
63
|
-
]
|
64
|
-
}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should accept custom timespan" do
|
69
|
-
Timecop.freeze(@current_time + interval) do
|
70
|
-
widget.data(timespan: timespan)[:series][:rows].size.should == 1
|
71
|
-
widget.data(timespan: timespan + interval)[:series][:rows].size.should == 2
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
4
|
+
it_should_behave_like "widget"
|
77
5
|
end
|
78
6
|
|
@@ -1,78 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe PulseMeter::Visualize::Widgets::Table do
|
4
|
-
|
5
|
-
let!(:a_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:a_sensor, :ttl => 1000, :interval => interval, annotation: 'A') }
|
6
|
-
let!(:b_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:b_sensor, :ttl => 1000, :interval => interval, annotation: 'B') }
|
7
|
-
|
8
|
-
let(:widget_name){ "some_widget" }
|
9
|
-
|
10
|
-
let(:redraw_interval){5}
|
11
|
-
let(:values_label){'xxxx'}
|
12
|
-
let(:width){6}
|
13
|
-
let(:timespan){interval * 2}
|
14
|
-
let(:a_color){'#FF0000'}
|
15
|
-
let(:b_color){'#FFFF00'}
|
16
|
-
|
17
|
-
let(:interval_start){ Time.at((Time.now.to_i / interval) * interval) }
|
18
|
-
|
19
|
-
let(:widget) do
|
20
|
-
w = PulseMeter::Visualize::DSL::Widgets::Table.new(widget_name)
|
21
|
-
w.redraw_interval redraw_interval
|
22
|
-
w.width width
|
23
|
-
w.sensor :a_sensor, color: a_color
|
24
|
-
w.sensor :b_sensor, color: b_color
|
25
|
-
w.gchart_options a: 1
|
26
|
-
w.timespan timespan
|
27
|
-
w.to_data
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#data" do
|
31
|
-
it "should contain type, title, redraw_interval, width, gchart_options, timespan attriutes" do
|
32
|
-
wdata = widget.data
|
33
|
-
wdata[:type].should == 'table'
|
34
|
-
wdata[:title].should == widget_name
|
35
|
-
wdata[:redraw_interval].should == redraw_interval
|
36
|
-
wdata[:width].should == width
|
37
|
-
wdata[:gchart_options].should == {a: 1}
|
38
|
-
wdata[:timespan].should == timespan
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "series attribute" do
|
42
|
-
before(:each) do
|
43
|
-
Timecop.freeze(interval_start + 1) do
|
44
|
-
a_sensor.event(12)
|
45
|
-
b_sensor.event(33)
|
46
|
-
end
|
47
|
-
Timecop.freeze(interval_start + interval + 1) do
|
48
|
-
a_sensor.event(111)
|
49
|
-
end
|
50
|
-
@current_time = interval_start + 2 * interval - 1
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should contain valid series" do
|
54
|
-
Timecop.freeze(@current_time) do
|
55
|
-
widget.data[:series].should ==
|
56
|
-
{
|
57
|
-
titles: [a_sensor.annotation, b_sensor.annotation],
|
58
|
-
rows: [[interval_start.to_i * 1000, 12, 33]],
|
59
|
-
options: [
|
60
|
-
{color: a_color},
|
61
|
-
{color: b_color}
|
62
|
-
]
|
63
|
-
}
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should accept custom timespan" do
|
68
|
-
Timecop.freeze(@current_time + interval) do
|
69
|
-
widget.data(timespan: timespan)[:series][:rows].size.should == 1
|
70
|
-
widget.data(timespan: timespan + interval)[:series][:rows].size.should == 2
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
4
|
+
it_should_behave_like "widget"
|
76
5
|
end
|
77
6
|
|
78
|
-
|
@@ -160,6 +160,16 @@ shared_examples_for "timeline sensor" do |extra_init_values, default_event|
|
|
160
160
|
redis.keys(sensor.data_key(@interval_id)).count.should == 0
|
161
161
|
end
|
162
162
|
end
|
163
|
+
|
164
|
+
it "should not store summarized data if it already exists" do
|
165
|
+
data_key = sensor.data_key(@interval_id)
|
166
|
+
redis.set(data_key, :dummy)
|
167
|
+
Timecop.freeze(@start_of_interval) do
|
168
|
+
sensor.event(sample_event)
|
169
|
+
sensor.reduce(@interval_id)
|
170
|
+
redis.get(data_key).should == "dummy"
|
171
|
+
end
|
172
|
+
end
|
163
173
|
end
|
164
174
|
|
165
175
|
describe "#reduce_all_raw" do
|
@@ -0,0 +1,97 @@
|
|
1
|
+
shared_examples_for "widget" do
|
2
|
+
let(:interval){ 100 }
|
3
|
+
let!(:a_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:a_sensor, :ttl => 1000, :interval => interval, annotation: 'A') }
|
4
|
+
let!(:b_sensor){ PulseMeter::Sensor::Timelined::Counter.new(:b_sensor, :ttl => 1000, :interval => interval, annotation: 'B') }
|
5
|
+
|
6
|
+
let(:widget_name){ "some_widget" }
|
7
|
+
|
8
|
+
let(:redraw_interval){5}
|
9
|
+
let(:values_label){'xxxx'}
|
10
|
+
let(:width){6}
|
11
|
+
let(:timespan){interval * 2}
|
12
|
+
let(:a_color){'#FF0000'}
|
13
|
+
let(:b_color){'#FFFF00'}
|
14
|
+
|
15
|
+
let(:interval_start){ Time.at((Time.now.to_i / interval) * interval) }
|
16
|
+
|
17
|
+
def constantize(const_name)
|
18
|
+
const_name.to_s.split('::').reduce(Module, :const_get)
|
19
|
+
end
|
20
|
+
|
21
|
+
def class_name
|
22
|
+
described_class.to_s.split('::').last
|
23
|
+
end
|
24
|
+
|
25
|
+
def dsl_class
|
26
|
+
constantize "PulseMeter::Visualize::DSL::Widgets::#{class_name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:widget) do
|
30
|
+
w = dsl_class.new(widget_name)
|
31
|
+
w.redraw_interval redraw_interval
|
32
|
+
w.width width
|
33
|
+
w.sensor :a_sensor, color: a_color
|
34
|
+
w.sensor :b_sensor, color: b_color
|
35
|
+
w.gchart_options a: 1
|
36
|
+
w.timespan timespan
|
37
|
+
w.to_data
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#data" do
|
41
|
+
it "should contain type, title, redraw_interval, width, gchart_options, timespan attriutes" do
|
42
|
+
wdata = widget.data
|
43
|
+
wdata[:type].should == class_name.downcase
|
44
|
+
wdata[:title].should == widget_name
|
45
|
+
wdata[:redraw_interval].should == redraw_interval
|
46
|
+
wdata[:width].should == width
|
47
|
+
wdata[:gchart_options].should == {a: 1}
|
48
|
+
wdata[:timespan].should == timespan
|
49
|
+
wdata[:interval].should == interval
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "series attribute" do
|
53
|
+
before(:each) do
|
54
|
+
Timecop.freeze(interval_start + 1) do
|
55
|
+
a_sensor.event(12)
|
56
|
+
b_sensor.event(33)
|
57
|
+
end
|
58
|
+
Timecop.freeze(interval_start + interval + 1) do
|
59
|
+
a_sensor.event(111)
|
60
|
+
end
|
61
|
+
@current_time = interval_start + 2 * interval - 1
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should contain valid series" do
|
65
|
+
Timecop.freeze(@current_time) do
|
66
|
+
widget.data[:series].should ==
|
67
|
+
{
|
68
|
+
titles: [a_sensor.annotation, b_sensor.annotation],
|
69
|
+
rows: [[interval_start.to_i * 1000, 12, 33]],
|
70
|
+
options: [
|
71
|
+
{color: a_color},
|
72
|
+
{color: b_color}
|
73
|
+
]
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should accept custom timespan" do
|
79
|
+
Timecop.freeze(@current_time + interval) do
|
80
|
+
widget.data(timespan: timespan)[:series][:rows].size.should == 1
|
81
|
+
widget.data(timespan: timespan + interval)[:series][:rows].size.should == 2
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should accept start_time and end_time" do
|
86
|
+
Timecop.freeze(@current_time + interval) do
|
87
|
+
widget.data(start_time: (Time.now - timespan).to_i)[:series][:rows].size.should == 1
|
88
|
+
widget.data(
|
89
|
+
start_time: (Time.now - interval - timespan).to_i,
|
90
|
+
end_time: Time.now.to_i
|
91
|
+
)[:series][:rows].size.should == 2
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,6 +18,7 @@ Dir['spec/shared_examples/**/*.rb'].each{|f| require File.join(ROOT,f)}
|
|
18
18
|
RSpec.configure do |config|
|
19
19
|
config.before(:each) do
|
20
20
|
PulseMeter.redis = MockRedis.new
|
21
|
+
Timecop.return
|
21
22
|
end
|
22
23
|
config.filter_run :focus => true
|
23
24
|
config.run_all_when_everything_filtered = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulse-meter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gon-sinatra
|
@@ -140,6 +140,22 @@ dependencies:
|
|
140
140
|
- - ! '>='
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: coffee-script
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
type: :development
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
143
159
|
- !ruby/object:Gem::Dependency
|
144
160
|
name: foreman
|
145
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,6 +188,22 @@ dependencies:
|
|
172
188
|
- - ! '>='
|
173
189
|
- !ruby/object:Gem::Version
|
174
190
|
version: '0'
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: listen
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
199
|
+
type: :development
|
200
|
+
prerelease: false
|
201
|
+
version_requirements: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
175
207
|
- !ruby/object:Gem::Dependency
|
176
208
|
name: mock_redis
|
177
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +252,22 @@ dependencies:
|
|
220
252
|
- - ! '>='
|
221
253
|
- !ruby/object:Gem::Version
|
222
254
|
version: '0'
|
255
|
+
- !ruby/object:Gem::Dependency
|
256
|
+
name: rb-fsevent
|
257
|
+
requirement: !ruby/object:Gem::Requirement
|
258
|
+
none: false
|
259
|
+
requirements:
|
260
|
+
- - ! '>='
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
version: '0'
|
263
|
+
type: :development
|
264
|
+
prerelease: false
|
265
|
+
version_requirements: !ruby/object:Gem::Requirement
|
266
|
+
none: false
|
267
|
+
requirements:
|
268
|
+
- - ! '>='
|
269
|
+
- !ruby/object:Gem::Version
|
270
|
+
version: '0'
|
223
271
|
- !ruby/object:Gem::Dependency
|
224
272
|
name: redcarpet
|
225
273
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,6 +316,22 @@ dependencies:
|
|
268
316
|
- - ! '>='
|
269
317
|
- !ruby/object:Gem::Version
|
270
318
|
version: '0'
|
319
|
+
- !ruby/object:Gem::Dependency
|
320
|
+
name: sprockets
|
321
|
+
requirement: !ruby/object:Gem::Requirement
|
322
|
+
none: false
|
323
|
+
requirements:
|
324
|
+
- - ! '>='
|
325
|
+
- !ruby/object:Gem::Version
|
326
|
+
version: '0'
|
327
|
+
type: :development
|
328
|
+
prerelease: false
|
329
|
+
version_requirements: !ruby/object:Gem::Requirement
|
330
|
+
none: false
|
331
|
+
requirements:
|
332
|
+
- - ! '>='
|
333
|
+
- !ruby/object:Gem::Version
|
334
|
+
version: '0'
|
271
335
|
- !ruby/object:Gem::Dependency
|
272
336
|
name: timecop
|
273
337
|
requirement: !ruby/object:Gem::Requirement
|
@@ -337,6 +401,7 @@ files:
|
|
337
401
|
- lib/pulse-meter/mixins/cmd.rb
|
338
402
|
- lib/pulse-meter/mixins/dumper.rb
|
339
403
|
- lib/pulse-meter/mixins/utils.rb
|
404
|
+
- lib/pulse-meter/observer.rb
|
340
405
|
- lib/pulse-meter/sensor.rb
|
341
406
|
- lib/pulse-meter/sensor/base.rb
|
342
407
|
- lib/pulse-meter/sensor/configuration.rb
|
@@ -354,6 +419,7 @@ files:
|
|
354
419
|
- lib/pulse-meter/sensor/timelined/max.rb
|
355
420
|
- lib/pulse-meter/sensor/timelined/median.rb
|
356
421
|
- lib/pulse-meter/sensor/timelined/min.rb
|
422
|
+
- lib/pulse-meter/sensor/timelined/multi_percentile.rb
|
357
423
|
- lib/pulse-meter/sensor/timelined/percentile.rb
|
358
424
|
- lib/pulse-meter/sensor/timelined/uniq_counter.rb
|
359
425
|
- lib/pulse-meter/sensor/uniq_counter.rb
|
@@ -364,6 +430,32 @@ files:
|
|
364
430
|
- lib/pulse-meter/version.rb
|
365
431
|
- lib/pulse-meter/visualize/app.rb
|
366
432
|
- lib/pulse-meter/visualize/base.rb
|
433
|
+
- lib/pulse-meter/visualize/coffee/application.coffee
|
434
|
+
- lib/pulse-meter/visualize/coffee/collections/page_info_list.coffee
|
435
|
+
- lib/pulse-meter/visualize/coffee/collections/sensor_info_list.coffee
|
436
|
+
- lib/pulse-meter/visualize/coffee/collections/widget_list.coffee
|
437
|
+
- lib/pulse-meter/visualize/coffee/extensions.coffee
|
438
|
+
- lib/pulse-meter/visualize/coffee/models/dinamic_widget.coffee
|
439
|
+
- lib/pulse-meter/visualize/coffee/models/page_info.coffee
|
440
|
+
- lib/pulse-meter/visualize/coffee/models/sensor_info.coffee
|
441
|
+
- lib/pulse-meter/visualize/coffee/models/widget.coffee
|
442
|
+
- lib/pulse-meter/visualize/coffee/presenters/area.coffee
|
443
|
+
- lib/pulse-meter/visualize/coffee/presenters/gauge.coffee
|
444
|
+
- lib/pulse-meter/visualize/coffee/presenters/line.coffee
|
445
|
+
- lib/pulse-meter/visualize/coffee/presenters/pie.coffee
|
446
|
+
- lib/pulse-meter/visualize/coffee/presenters/series.coffee
|
447
|
+
- lib/pulse-meter/visualize/coffee/presenters/table.coffee
|
448
|
+
- lib/pulse-meter/visualize/coffee/presenters/timeline.coffee
|
449
|
+
- lib/pulse-meter/visualize/coffee/presenters/widget.coffee
|
450
|
+
- lib/pulse-meter/visualize/coffee/router.coffee
|
451
|
+
- lib/pulse-meter/visualize/coffee/views/dynamic_chart.coffee
|
452
|
+
- lib/pulse-meter/visualize/coffee/views/dynamic_widget.coffee
|
453
|
+
- lib/pulse-meter/visualize/coffee/views/page_title.coffee
|
454
|
+
- lib/pulse-meter/visualize/coffee/views/page_titles.coffee
|
455
|
+
- lib/pulse-meter/visualize/coffee/views/sensor_info_list.coffee
|
456
|
+
- lib/pulse-meter/visualize/coffee/views/widget.coffee
|
457
|
+
- lib/pulse-meter/visualize/coffee/views/widget_chart.coffee
|
458
|
+
- lib/pulse-meter/visualize/coffee/views/widget_list.coffee
|
367
459
|
- lib/pulse-meter/visualize/dsl/base.rb
|
368
460
|
- lib/pulse-meter/visualize/dsl/errors.rb
|
369
461
|
- lib/pulse-meter/visualize/dsl/layout.rb
|
@@ -380,14 +472,31 @@ files:
|
|
380
472
|
- lib/pulse-meter/visualize/public/css/application.css
|
381
473
|
- lib/pulse-meter/visualize/public/css/bootstrap.css
|
382
474
|
- lib/pulse-meter/visualize/public/css/bootstrap.min.css
|
475
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_flat_0_aaaaaa_40x100.png
|
476
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_glass_55_fbf9ee_1x400.png
|
477
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_glass_65_ffffff_1x400.png
|
478
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_dadada_1x400.png
|
479
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_e6e6e6_1x400.png
|
480
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_ffffff_1x400.png
|
481
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
482
|
+
- lib/pulse-meter/visualize/public/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png
|
483
|
+
- lib/pulse-meter/visualize/public/css/images/ui-icons_222222_256x240.png
|
484
|
+
- lib/pulse-meter/visualize/public/css/images/ui-icons_2e83ff_256x240.png
|
485
|
+
- lib/pulse-meter/visualize/public/css/images/ui-icons_454545_256x240.png
|
486
|
+
- lib/pulse-meter/visualize/public/css/images/ui-icons_888888_256x240.png
|
487
|
+
- lib/pulse-meter/visualize/public/css/images/ui-icons_cd0a0a_256x240.png
|
488
|
+
- lib/pulse-meter/visualize/public/css/images/ui-icons_f6cf3b_256x240.png
|
489
|
+
- lib/pulse-meter/visualize/public/css/jquery-ui-1.8.16.bootstrap.css
|
383
490
|
- lib/pulse-meter/visualize/public/favicon.ico
|
384
491
|
- lib/pulse-meter/visualize/public/img/glyphicons-halflings-white.png
|
385
492
|
- lib/pulse-meter/visualize/public/img/glyphicons-halflings.png
|
386
|
-
- lib/pulse-meter/visualize/public/js/application.coffee
|
387
493
|
- lib/pulse-meter/visualize/public/js/application.js
|
388
494
|
- lib/pulse-meter/visualize/public/js/backbone-min.js
|
389
495
|
- lib/pulse-meter/visualize/public/js/bootstrap.js
|
390
496
|
- lib/pulse-meter/visualize/public/js/jquery-1.7.2.min.js
|
497
|
+
- lib/pulse-meter/visualize/public/js/jquery-ui-1.8.16.bootstrap.min.js
|
498
|
+
- lib/pulse-meter/visualize/public/js/jquery-ui-1.8.23.custom.min.js
|
499
|
+
- lib/pulse-meter/visualize/public/js/jquery-ui-timepicker-addon.js
|
391
500
|
- lib/pulse-meter/visualize/public/js/json2.js
|
392
501
|
- lib/pulse-meter/visualize/public/js/underscore-min.js
|
393
502
|
- lib/pulse-meter/visualize/sensor.rb
|
@@ -410,6 +519,7 @@ files:
|
|
410
519
|
- spec/pulse_meter/mixins/cmd_spec.rb
|
411
520
|
- spec/pulse_meter/mixins/dumper_spec.rb
|
412
521
|
- spec/pulse_meter/mixins/utils_spec.rb
|
522
|
+
- spec/pulse_meter/observer_spec.rb
|
413
523
|
- spec/pulse_meter/sensor/base_spec.rb
|
414
524
|
- spec/pulse_meter/sensor/configuration_spec.rb
|
415
525
|
- spec/pulse_meter/sensor/counter_spec.rb
|
@@ -426,6 +536,7 @@ files:
|
|
426
536
|
- spec/pulse_meter/sensor/timelined/max_spec.rb
|
427
537
|
- spec/pulse_meter/sensor/timelined/median_spec.rb
|
428
538
|
- spec/pulse_meter/sensor/timelined/min_spec.rb
|
539
|
+
- spec/pulse_meter/sensor/timelined/multi_percentile_spec.rb
|
429
540
|
- spec/pulse_meter/sensor/timelined/percentile_spec.rb
|
430
541
|
- spec/pulse_meter/sensor/timelined/uniq_counter_spec.rb
|
431
542
|
- spec/pulse_meter/sensor/uniq_counter_spec.rb
|
@@ -453,6 +564,7 @@ files:
|
|
453
564
|
- spec/shared_examples/dsl_widget.rb
|
454
565
|
- spec/shared_examples/timeline_sensor.rb
|
455
566
|
- spec/shared_examples/timelined_subclass.rb
|
567
|
+
- spec/shared_examples/widget.rb
|
456
568
|
- spec/spec_helper.rb
|
457
569
|
- spec/support/matchers.rb
|
458
570
|
homepage: https://github.com/savonarola/pulse-meter
|
@@ -475,10 +587,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
475
587
|
version: '0'
|
476
588
|
segments:
|
477
589
|
- 0
|
478
|
-
hash:
|
590
|
+
hash: 2422587240922148030
|
479
591
|
requirements: []
|
480
592
|
rubyforge_project:
|
481
|
-
rubygems_version: 1.8.
|
593
|
+
rubygems_version: 1.8.23
|
482
594
|
signing_key:
|
483
595
|
specification_version: 3
|
484
596
|
summary: Lightweight Redis-based metrics aggregator and processor with CLI and simple
|
@@ -488,6 +600,7 @@ test_files:
|
|
488
600
|
- spec/pulse_meter/mixins/cmd_spec.rb
|
489
601
|
- spec/pulse_meter/mixins/dumper_spec.rb
|
490
602
|
- spec/pulse_meter/mixins/utils_spec.rb
|
603
|
+
- spec/pulse_meter/observer_spec.rb
|
491
604
|
- spec/pulse_meter/sensor/base_spec.rb
|
492
605
|
- spec/pulse_meter/sensor/configuration_spec.rb
|
493
606
|
- spec/pulse_meter/sensor/counter_spec.rb
|
@@ -504,6 +617,7 @@ test_files:
|
|
504
617
|
- spec/pulse_meter/sensor/timelined/max_spec.rb
|
505
618
|
- spec/pulse_meter/sensor/timelined/median_spec.rb
|
506
619
|
- spec/pulse_meter/sensor/timelined/min_spec.rb
|
620
|
+
- spec/pulse_meter/sensor/timelined/multi_percentile_spec.rb
|
507
621
|
- spec/pulse_meter/sensor/timelined/percentile_spec.rb
|
508
622
|
- spec/pulse_meter/sensor/timelined/uniq_counter_spec.rb
|
509
623
|
- spec/pulse_meter/sensor/uniq_counter_spec.rb
|
@@ -531,6 +645,7 @@ test_files:
|
|
531
645
|
- spec/shared_examples/dsl_widget.rb
|
532
646
|
- spec/shared_examples/timeline_sensor.rb
|
533
647
|
- spec/shared_examples/timelined_subclass.rb
|
648
|
+
- spec/shared_examples/widget.rb
|
534
649
|
- spec/spec_helper.rb
|
535
650
|
- spec/support/matchers.rb
|
536
651
|
has_rdoc:
|