pulse-meter 0.4.9 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/Rakefile +1 -48
  2. data/lib/pulse-meter.rb +1 -68
  3. data/lib/pulse-meter/visualizer.rb +1 -40
  4. data/pulse-meter.gemspec +4 -26
  5. metadata +10 -558
  6. data/Procfile +0 -3
  7. data/bin/pulse +0 -6
  8. data/examples/basic.ru +0 -145
  9. data/examples/basic_sensor_data.rb +0 -96
  10. data/examples/udp_benchmark.rb +0 -29
  11. data/lib/cmd.rb +0 -171
  12. data/lib/pulse-meter/command_aggregator/async.rb +0 -83
  13. data/lib/pulse-meter/command_aggregator/sync.rb +0 -18
  14. data/lib/pulse-meter/command_aggregator/udp.rb +0 -48
  15. data/lib/pulse-meter/extensions/enumerable.rb +0 -24
  16. data/lib/pulse-meter/mixins/cmd.rb +0 -46
  17. data/lib/pulse-meter/mixins/dumper.rb +0 -87
  18. data/lib/pulse-meter/mixins/utils.rb +0 -155
  19. data/lib/pulse-meter/observer.rb +0 -120
  20. data/lib/pulse-meter/observer/extended.rb +0 -34
  21. data/lib/pulse-meter/sensor.rb +0 -61
  22. data/lib/pulse-meter/sensor/base.rb +0 -88
  23. data/lib/pulse-meter/sensor/configuration.rb +0 -106
  24. data/lib/pulse-meter/sensor/counter.rb +0 -39
  25. data/lib/pulse-meter/sensor/hashed_counter.rb +0 -36
  26. data/lib/pulse-meter/sensor/hashed_indicator.rb +0 -24
  27. data/lib/pulse-meter/sensor/indicator.rb +0 -35
  28. data/lib/pulse-meter/sensor/multi.rb +0 -97
  29. data/lib/pulse-meter/sensor/timeline.rb +0 -236
  30. data/lib/pulse-meter/sensor/timeline_reduce.rb +0 -68
  31. data/lib/pulse-meter/sensor/timelined/average.rb +0 -32
  32. data/lib/pulse-meter/sensor/timelined/counter.rb +0 -23
  33. data/lib/pulse-meter/sensor/timelined/hashed_counter.rb +0 -31
  34. data/lib/pulse-meter/sensor/timelined/hashed_indicator.rb +0 -30
  35. data/lib/pulse-meter/sensor/timelined/indicator.rb +0 -23
  36. data/lib/pulse-meter/sensor/timelined/max.rb +0 -19
  37. data/lib/pulse-meter/sensor/timelined/median.rb +0 -14
  38. data/lib/pulse-meter/sensor/timelined/min.rb +0 -19
  39. data/lib/pulse-meter/sensor/timelined/multi_percentile.rb +0 -34
  40. data/lib/pulse-meter/sensor/timelined/percentile.rb +0 -22
  41. data/lib/pulse-meter/sensor/timelined/uniq_counter.rb +0 -22
  42. data/lib/pulse-meter/sensor/timelined/zset_based.rb +0 -38
  43. data/lib/pulse-meter/sensor/uniq_counter.rb +0 -24
  44. data/lib/pulse-meter/server.rb +0 -0
  45. data/lib/pulse-meter/server/command_line_options.rb +0 -0
  46. data/lib/pulse-meter/server/config_options.rb +0 -0
  47. data/lib/pulse-meter/server/sensors.rb +0 -0
  48. data/lib/pulse-meter/udp_server.rb +0 -45
  49. data/lib/pulse-meter/version.rb +0 -3
  50. data/lib/pulse-meter/visualize/app.rb +0 -78
  51. data/lib/pulse-meter/visualize/base.rb +0 -15
  52. data/lib/pulse-meter/visualize/coffee/application.coffee +0 -40
  53. data/lib/pulse-meter/visualize/coffee/collections/page_info_list.coffee +0 -17
  54. data/lib/pulse-meter/visualize/coffee/collections/sensor_info_list.coffee +0 -4
  55. data/lib/pulse-meter/visualize/coffee/collections/widget_list.coffee +0 -14
  56. data/lib/pulse-meter/visualize/coffee/extensions.coffee +0 -26
  57. data/lib/pulse-meter/visualize/coffee/models/dinamic_widget.coffee +0 -34
  58. data/lib/pulse-meter/visualize/coffee/models/page_info.coffee +0 -2
  59. data/lib/pulse-meter/visualize/coffee/models/sensor_info.coffee +0 -2
  60. data/lib/pulse-meter/visualize/coffee/models/widget.coffee +0 -54
  61. data/lib/pulse-meter/visualize/coffee/presenters/area.coffee +0 -2
  62. data/lib/pulse-meter/visualize/coffee/presenters/gauge.coffee +0 -11
  63. data/lib/pulse-meter/visualize/coffee/presenters/line.coffee +0 -2
  64. data/lib/pulse-meter/visualize/coffee/presenters/pie.coffee +0 -20
  65. data/lib/pulse-meter/visualize/coffee/presenters/series.coffee +0 -44
  66. data/lib/pulse-meter/visualize/coffee/presenters/table.coffee +0 -10
  67. data/lib/pulse-meter/visualize/coffee/presenters/timeline.coffee +0 -13
  68. data/lib/pulse-meter/visualize/coffee/presenters/widget.coffee +0 -65
  69. data/lib/pulse-meter/visualize/coffee/router.coffee +0 -21
  70. data/lib/pulse-meter/visualize/coffee/views/dynamic_chart.coffee +0 -91
  71. data/lib/pulse-meter/visualize/coffee/views/dynamic_widget.coffee +0 -58
  72. data/lib/pulse-meter/visualize/coffee/views/page_title.coffee +0 -17
  73. data/lib/pulse-meter/visualize/coffee/views/page_titles.coffee +0 -15
  74. data/lib/pulse-meter/visualize/coffee/views/sensor_info_list.coffee +0 -19
  75. data/lib/pulse-meter/visualize/coffee/views/widget.coffee +0 -99
  76. data/lib/pulse-meter/visualize/coffee/views/widget_chart.coffee +0 -13
  77. data/lib/pulse-meter/visualize/coffee/views/widget_list.coffee +0 -15
  78. data/lib/pulse-meter/visualize/dsl/base.rb +0 -131
  79. data/lib/pulse-meter/visualize/dsl/errors.rb +0 -40
  80. data/lib/pulse-meter/visualize/dsl/layout.rb +0 -27
  81. data/lib/pulse-meter/visualize/dsl/page.rb +0 -33
  82. data/lib/pulse-meter/visualize/dsl/sensor.rb +0 -20
  83. data/lib/pulse-meter/visualize/dsl/widget.rb +0 -37
  84. data/lib/pulse-meter/visualize/dsl/widgets/area.rb +0 -20
  85. data/lib/pulse-meter/visualize/dsl/widgets/gauge.rb +0 -12
  86. data/lib/pulse-meter/visualize/dsl/widgets/line.rb +0 -21
  87. data/lib/pulse-meter/visualize/dsl/widgets/pie.rb +0 -16
  88. data/lib/pulse-meter/visualize/dsl/widgets/table.rb +0 -19
  89. data/lib/pulse-meter/visualize/layout.rb +0 -79
  90. data/lib/pulse-meter/visualize/page.rb +0 -25
  91. data/lib/pulse-meter/visualize/public/css/application.css +0 -56
  92. data/lib/pulse-meter/visualize/public/css/bootstrap.css +0 -4883
  93. data/lib/pulse-meter/visualize/public/css/bootstrap.min.css +0 -729
  94. data/lib/pulse-meter/visualize/public/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  95. data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  96. data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  97. data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  98. data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  99. data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
  100. data/lib/pulse-meter/visualize/public/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  101. data/lib/pulse-meter/visualize/public/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
  102. data/lib/pulse-meter/visualize/public/css/images/ui-icons_222222_256x240.png +0 -0
  103. data/lib/pulse-meter/visualize/public/css/images/ui-icons_2e83ff_256x240.png +0 -0
  104. data/lib/pulse-meter/visualize/public/css/images/ui-icons_454545_256x240.png +0 -0
  105. data/lib/pulse-meter/visualize/public/css/images/ui-icons_888888_256x240.png +0 -0
  106. data/lib/pulse-meter/visualize/public/css/images/ui-icons_cd0a0a_256x240.png +0 -0
  107. data/lib/pulse-meter/visualize/public/css/images/ui-icons_f6cf3b_256x240.png +0 -0
  108. data/lib/pulse-meter/visualize/public/css/jquery-ui-1.8.16.bootstrap.css +0 -1320
  109. data/lib/pulse-meter/visualize/public/favicon.ico +0 -208
  110. data/lib/pulse-meter/visualize/public/img/glyphicons-halflings-white.png +0 -0
  111. data/lib/pulse-meter/visualize/public/img/glyphicons-halflings.png +0 -0
  112. data/lib/pulse-meter/visualize/public/js/application.js +0 -973
  113. data/lib/pulse-meter/visualize/public/js/backbone-min.js +0 -38
  114. data/lib/pulse-meter/visualize/public/js/bootstrap.js +0 -1835
  115. data/lib/pulse-meter/visualize/public/js/jquery-1.7.2.min.js +0 -4
  116. data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.16.bootstrap.min.js +0 -791
  117. data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.23.custom.min.js +0 -21
  118. data/lib/pulse-meter/visualize/public/js/jquery-ui-timepicker-addon.js +0 -1687
  119. data/lib/pulse-meter/visualize/public/js/json2.js +0 -487
  120. data/lib/pulse-meter/visualize/public/js/underscore-min.js +0 -32
  121. data/lib/pulse-meter/visualize/sensor.rb +0 -63
  122. data/lib/pulse-meter/visualize/series_extractor.rb +0 -107
  123. data/lib/pulse-meter/visualize/views/main.haml +0 -30
  124. data/lib/pulse-meter/visualize/views/sensors.haml +0 -76
  125. data/lib/pulse-meter/visualize/views/widgets/area.haml +0 -53
  126. data/lib/pulse-meter/visualize/views/widgets/extend_options.haml +0 -11
  127. data/lib/pulse-meter/visualize/views/widgets/gauge.haml +0 -13
  128. data/lib/pulse-meter/visualize/views/widgets/line.haml +0 -54
  129. data/lib/pulse-meter/visualize/views/widgets/pie.haml +0 -13
  130. data/lib/pulse-meter/visualize/views/widgets/table.haml +0 -45
  131. data/lib/pulse-meter/visualize/widget.rb +0 -38
  132. data/lib/pulse-meter/visualize/widgets/gauge.rb +0 -47
  133. data/lib/pulse-meter/visualize/widgets/pie.rb +0 -36
  134. data/lib/pulse-meter/visualize/widgets/timeline.rb +0 -114
  135. data/spec/pulse_meter/command_aggregator/async_spec.rb +0 -53
  136. data/spec/pulse_meter/command_aggregator/sync_spec.rb +0 -25
  137. data/spec/pulse_meter/command_aggregator/udp_spec.rb +0 -45
  138. data/spec/pulse_meter/extensions/enumerable_spec.rb +0 -58
  139. data/spec/pulse_meter/mixins/cmd_spec.rb +0 -117
  140. data/spec/pulse_meter/mixins/dumper_spec.rb +0 -162
  141. data/spec/pulse_meter/mixins/utils_spec.rb +0 -212
  142. data/spec/pulse_meter/observer/extended_spec.rb +0 -92
  143. data/spec/pulse_meter/observer_spec.rb +0 -207
  144. data/spec/pulse_meter/sensor/base_spec.rb +0 -106
  145. data/spec/pulse_meter/sensor/configuration_spec.rb +0 -103
  146. data/spec/pulse_meter/sensor/counter_spec.rb +0 -54
  147. data/spec/pulse_meter/sensor/hashed_counter_spec.rb +0 -43
  148. data/spec/pulse_meter/sensor/hashed_indicator_spec.rb +0 -39
  149. data/spec/pulse_meter/sensor/indicator_spec.rb +0 -43
  150. data/spec/pulse_meter/sensor/multi_spec.rb +0 -137
  151. data/spec/pulse_meter/sensor/timeline_spec.rb +0 -88
  152. data/spec/pulse_meter/sensor/timelined/average_spec.rb +0 -6
  153. data/spec/pulse_meter/sensor/timelined/counter_spec.rb +0 -6
  154. data/spec/pulse_meter/sensor/timelined/hashed_counter_spec.rb +0 -8
  155. data/spec/pulse_meter/sensor/timelined/hashed_indicator_spec.rb +0 -8
  156. data/spec/pulse_meter/sensor/timelined/indicator_spec.rb +0 -6
  157. data/spec/pulse_meter/sensor/timelined/max_spec.rb +0 -7
  158. data/spec/pulse_meter/sensor/timelined/median_spec.rb +0 -7
  159. data/spec/pulse_meter/sensor/timelined/min_spec.rb +0 -7
  160. data/spec/pulse_meter/sensor/timelined/multi_percentile_spec.rb +0 -21
  161. data/spec/pulse_meter/sensor/timelined/percentile_spec.rb +0 -17
  162. data/spec/pulse_meter/sensor/timelined/uniq_counter_spec.rb +0 -9
  163. data/spec/pulse_meter/sensor/uniq_counter_spec.rb +0 -28
  164. data/spec/pulse_meter/udp_server_spec.rb +0 -36
  165. data/spec/pulse_meter/visualize/app_spec.rb +0 -27
  166. data/spec/pulse_meter/visualize/dsl/layout_spec.rb +0 -64
  167. data/spec/pulse_meter/visualize/dsl/page_spec.rb +0 -62
  168. data/spec/pulse_meter/visualize/dsl/sensor_spec.rb +0 -30
  169. data/spec/pulse_meter/visualize/dsl/widget_spec.rb +0 -6
  170. data/spec/pulse_meter/visualize/dsl/widgets/area_spec.rb +0 -44
  171. data/spec/pulse_meter/visualize/dsl/widgets/gauge_spec.rb +0 -22
  172. data/spec/pulse_meter/visualize/dsl/widgets/line_spec.rb +0 -44
  173. data/spec/pulse_meter/visualize/dsl/widgets/pie_spec.rb +0 -35
  174. data/spec/pulse_meter/visualize/dsl/widgets/table_spec.rb +0 -36
  175. data/spec/pulse_meter/visualize/layout_spec.rb +0 -54
  176. data/spec/pulse_meter/visualize/page_spec.rb +0 -153
  177. data/spec/pulse_meter/visualize/sensor_spec.rb +0 -120
  178. data/spec/pulse_meter/visualize/series_extractor_spec.rb +0 -80
  179. data/spec/pulse_meter/visualize/widgets/area_spec.rb +0 -6
  180. data/spec/pulse_meter/visualize/widgets/gauge_spec.rb +0 -63
  181. data/spec/pulse_meter/visualize/widgets/line_spec.rb +0 -6
  182. data/spec/pulse_meter/visualize/widgets/pie_spec.rb +0 -73
  183. data/spec/pulse_meter/visualize/widgets/table_spec.rb +0 -6
  184. data/spec/pulse_meter/visualizer_spec.rb +0 -42
  185. data/spec/pulse_meter_spec.rb +0 -73
  186. data/spec/shared_examples/dsl_widget.rb +0 -106
  187. data/spec/shared_examples/timeline_sensor.rb +0 -439
  188. data/spec/shared_examples/timelined_subclass.rb +0 -23
  189. data/spec/shared_examples/widget.rb +0 -97
  190. data/spec/spec_helper.rb +0 -40
  191. data/spec/support/matchers.rb +0 -34
  192. data/spec/support/observered.rb +0 -40
@@ -1,23 +0,0 @@
1
- shared_examples_for "timelined subclass" do |events, result, extra_options|
2
- let(:name){ :counter }
3
- let(:ttl){ 100 }
4
- let(:raw_data_ttl){ 10 }
5
- let(:interval){ 5 }
6
- let(:reduce_delay){ 3 }
7
- let(:init_values){ {:ttl => ttl, :raw_data_ttl => raw_data_ttl, :interval => interval, :reduce_delay => reduce_delay}.merge(extra_options || {}) }
8
- let(:sensor){ described_class.new(name, init_values) }
9
- let(:epsilon) {1}
10
-
11
- it "should calculate summarized value #{result.inspect} of #{events.inspect}" do
12
- interval_id = 0
13
- start_of_interval = Time.at(interval_id)
14
- Timecop.freeze(start_of_interval) do
15
- events.each {|e| sensor.event(e)}
16
- end
17
- Timecop.freeze(start_of_interval + interval) do
18
- data = sensor.timeline(interval + epsilon).first
19
- data.value.should be_generally_equal(sensor.deflate_safe(result))
20
- end
21
- end
22
-
23
- end
@@ -1,97 +0,0 @@
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
@@ -1,40 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- $:.unshift File.expand_path('../../lib/', __FILE__)
4
-
5
- ROOT = File.expand_path('../..', __FILE__)
6
-
7
- Bundler.require(:default, :test, :development)
8
-
9
- SimpleCov.start
10
-
11
- require 'pulse-meter'
12
- require 'pulse-meter/visualizer'
13
- PulseMeter.redis = MockRedis.new
14
-
15
- require 'rack/test'
16
-
17
- Dir['spec/support/**/*.rb'].each{|f| require File.join(ROOT, f) }
18
- Dir['spec/shared_examples/**/*.rb'].each{|f| require File.join(ROOT,f)}
19
-
20
-
21
- require 'aquarium'
22
- include Aquarium::Aspects
23
-
24
- Aspect.new :after, :calls_to => [:event, :event_at], :for_types => [PulseMeter::Sensor::Base, PulseMeter::Sensor::Timeline] do |jp, obj, *args|
25
- PulseMeter.command_aggregator.wait_for_pending_events
26
- end
27
-
28
- PulseMeter.command_aggregator.max_queue_length = 20
29
-
30
- RSpec.configure do |config|
31
- config.before(:each) do
32
- PulseMeter.redis = MockRedis.new
33
- Timecop.return
34
- PulseMeter.logger = Logger.new("/dev/null")
35
- end
36
- config.filter_run :focus => true
37
- config.run_all_when_everything_filtered = true
38
- config.include(Matchers)
39
- end
40
-
@@ -1,34 +0,0 @@
1
- module Matchers
2
-
3
- class GenerallyEqual
4
-
5
- EPSILON = 0.0001
6
-
7
- def initialize(expected)
8
- @expected = expected
9
- end
10
-
11
- def matches?(actual)
12
- @actual = actual
13
-
14
- if @actual.kind_of?(Float) || @expected.kind_of?(Float)
15
- (@expected - EPSILON .. @expected + EPSILON).include? @actual
16
- else
17
- @expected == @actual
18
- end
19
- end
20
-
21
- def failure_message_for_should
22
- "expected #{@actual.inspect} to be generally equal to #{@expected.inspect}"
23
- end
24
-
25
- def failure_message_for_should_not
26
- "expected #{@actual.inspect} not to be generally equal to #{@expected.inspect}"
27
- end
28
- end
29
-
30
- def be_generally_equal(expected)
31
- GenerallyEqual.new(expected)
32
- end
33
-
34
- end
@@ -1,40 +0,0 @@
1
- class ObservedDummy
2
- attr_reader :count
3
- @@count = 0
4
-
5
- def initialize
6
- @count = 0
7
- end
8
-
9
- def incr(value = 1, &proc)
10
- Timecop.travel(Time.now + 1)
11
- @count += value
12
- @count += proc.call if proc
13
- @count
14
- end
15
-
16
- def error
17
- raise RuntimeError
18
- end
19
-
20
- class << self
21
- def count
22
- @@count
23
- end
24
-
25
- def reset
26
- @@count = 0
27
- end
28
-
29
- def incr(value = 1, &proc)
30
- Timecop.travel(Time.now + 1)
31
- @@count += value
32
- @@count += proc.call if proc
33
- @@count
34
- end
35
-
36
- def error
37
- raise RuntimeError
38
- end
39
- end
40
- end