fnordmetric 1.2.1 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -146,3 +146,4 @@ require "fnordmetric/widgets/bars_widget"
146
146
  require "fnordmetric/widgets/toplist_widget"
147
147
  require "fnordmetric/widgets/pie_widget"
148
148
  require "fnordmetric/widgets/html_widget"
149
+ require "fnordmetric/enterprise/compatibility_handler"
@@ -0,0 +1,42 @@
1
+ module FnordMetric::Enterprise
2
+
3
+ CompatibilityHandler = proc do
4
+ if data[:_cmd]
5
+ cmd = data[:_cmd].to_s
6
+ else
7
+ FnordMetric.error("missing key: _cmd")
8
+ next
9
+ end
10
+
11
+ if m = cmd.match(/^SAMPLE (.*)(delta|mean)-([0-9]+) ([0-9]+)$/)
12
+ gauge_type = m[2].to_sym
13
+ gauge_tick = m[3].to_i
14
+ gauge_key = :"#{m[1]}#{gauge_type}-#{gauge_tick}"
15
+ op_value = m[4].to_i
16
+ else
17
+ FnordMetric.error("invalid _cmd")
18
+ next
19
+ end
20
+
21
+ gauge = if namespace.gauges.has_key?(gauge_key)
22
+ namespace.gauges[gauge_key]
23
+ else
24
+ namespace.opt_gauge(gauge_key,
25
+ :flush_interval => gauge_tick,
26
+ :average => (gauge_type == :mean),
27
+ :zero_config => true)
28
+ end
29
+
30
+ case gauge_type
31
+
32
+ when :delta
33
+ incr gauge, op_value
34
+
35
+ when :mean
36
+ incr_avg gauge, op_value
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -38,6 +38,12 @@ class FnordMetric::Namespace
38
38
  event[:_session_key] = announce_to_session(event).session_key
39
39
  end
40
40
 
41
+ if event[:_type].to_sym == :_enterprise
42
+ ctx = FnordMetric::Context.new(opts, FnordMetric::Enterprise::CompatibilityHandler)
43
+ ctx.call(event, @redis, self)
44
+ return self
45
+ end
46
+
41
47
  if FnordMetric::ZeroConfigGauge::TYPES.include?(event[:_type].to_sym)
42
48
  ctx = FnordMetric::Context.new(opts, FnordMetric::ZeroConfigGauge::Handler)
43
49
  ctx.call(event, @redis, self)
@@ -1,3 +1,3 @@
1
1
  module FnordMetric
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.4"
3
3
  end
@@ -16,7 +16,12 @@ class FnordMetric::Web
16
16
  middleware_stack = @opts[:use] || []
17
17
 
18
18
  websocket = FnordMetric::WebSocket.new
19
- webapp = FnordMetric::App.new(@opts)
19
+
20
+ webapp = if FnordMetric.options[:http_websocket_only]
21
+ lambda { |env| [204, {}, [""]] }
22
+ else
23
+ FnordMetric::App.new(@opts)
24
+ end
20
25
 
21
26
  dispatch = Rack::Builder.app do
22
27
  use Rack::CommonLogger
@@ -33,6 +38,7 @@ class FnordMetric::Web
33
38
 
34
39
  run webapp
35
40
  end
41
+
36
42
  end
37
43
 
38
44
  unless ["thin", "hatetepe"].include? server
@@ -120,6 +120,51 @@ describe FnordMetric::GaugeModifiers do
120
120
 
121
121
  end
122
122
 
123
+
124
+ describe "increment enterprise backwards compatibility gauges" do
125
+
126
+ it "should create and increment enterprise comaptibility gauges: delta" do
127
+ @namespace.announce(
128
+ :_type => "_enterprise", :_time => 1360584960, :_eid => 1234,
129
+ :_cmd => "SAMPLE sales-per-second-delta-20 42")
130
+
131
+ @namespace.gauges[:"sales-per-second-delta-20"].should be_a(Gauge)
132
+
133
+ gauge_key = "fnordmetric-myns_213-gauge-sales-per-second-delta-20-20"
134
+ puts gauge_key
135
+ @redis.hget(gauge_key, "1360584960").should == "42"
136
+
137
+ @namespace.announce(
138
+ :_type => "_enterprise", :_time => 1360584960, :_eid => 1234,
139
+ :_cmd => "SAMPLE sales-per-second-delta-20 11")
140
+
141
+
142
+ @redis.hget(gauge_key, "1360584960").should == "53"
143
+ @namespace.gauges[:"sales-per-second-delta-20"].value_at(1360584961).should == "53"
144
+ end
145
+
146
+ it "should create and increment enterprise comaptibility gauges: mean" do
147
+ @namespace.announce(
148
+ :_type => "_enterprise", :_time => 1360584960, :_eid => 1234,
149
+ :_cmd => "SAMPLE sales-per-second-mean-10 5")
150
+
151
+ @namespace.gauges[:"sales-per-second-mean-10"].should be_a(Gauge)
152
+
153
+ gauge_key = "fnordmetric-myns_213-gauge-sales-per-second-mean-10-10"
154
+ @redis.hget(gauge_key, "1360584960").should == "5"
155
+
156
+ @namespace.announce(
157
+ :_type => "_enterprise", :_time => 1360584960, :_eid => 1234,
158
+ :_cmd => "SAMPLE sales-per-second-mean-10 10")
159
+
160
+
161
+ @redis.hget(gauge_key, "1360584960").should == "15"
162
+ @namespace.gauges[:"sales-per-second-mean-10"].value_at(1360584961).should == 7.5
163
+ end
164
+
165
+
166
+ end
167
+
123
168
  describe "increment non-progressive gauges" do
124
169
 
125
170
  it "should increment a non-progressive gauge by 1" do
@@ -20,6 +20,7 @@ FnordMetric.views.gaugeExplorer = (function(){
20
20
 
21
21
  function load(_elem){
22
22
  elem = _elem;
23
+ gauge_list = {};
23
24
 
24
25
  elem.html('<div class="navbar"></div><div class="ge_controlpanel">' +
25
26
  '<label>Select a Gauge</label><select class="ge_gauge_picker">' +
@@ -123,7 +124,6 @@ FnordMetric.views.gaugeExplorer = (function(){
123
124
 
124
125
  if (evt.type == "gauge_list_response"){
125
126
  $('.ge_gauge_picker', elem).html();
126
- gauge_list = {};
127
127
  var changed = false;
128
128
 
129
129
  $(evt.gauges).each(function(n, gauge){
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fnordmetric
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-13 00:00:00.000000000 Z
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &14744120 !ruby/object:Gem::Requirement
16
+ requirement: &19052860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *14744120
24
+ version_requirements: *19052860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redis
27
- requirement: &14743180 !ruby/object:Gem::Requirement
27
+ requirement: &19051780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.2.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *14743180
35
+ version_requirements: *19051780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: eventmachine
38
- requirement: &14742540 !ruby/object:Gem::Requirement
38
+ requirement: &19145540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *14742540
46
+ version_requirements: *19145540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: websocket-rack
49
- requirement: &14856940 !ruby/object:Gem::Requirement
49
+ requirement: &19144880 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.4.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *14856940
57
+ version_requirements: *19144880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: em-hiredis
60
- requirement: &14856440 !ruby/object:Gem::Requirement
60
+ requirement: &19144380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.1.1
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *14856440
68
+ version_requirements: *19144380
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
- requirement: &14856060 !ruby/object:Gem::Requirement
71
+ requirement: &19143980 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *14856060
79
+ version_requirements: *19143980
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: i18n
82
- requirement: &14855560 !ruby/object:Gem::Requirement
82
+ requirement: &19143460 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *14855560
90
+ version_requirements: *19143460
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: haml
93
- requirement: &14855080 !ruby/object:Gem::Requirement
93
+ requirement: &19143020 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *14855080
101
+ version_requirements: *19143020
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rack
104
- requirement: &14854660 !ruby/object:Gem::Requirement
104
+ requirement: &19142600 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *14854660
112
+ version_requirements: *19142600
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rack-test
115
- requirement: &14854240 !ruby/object:Gem::Requirement
115
+ requirement: &19142180 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *14854240
123
+ version_requirements: *19142180
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: yajl-ruby
126
- requirement: &14853820 !ruby/object:Gem::Requirement
126
+ requirement: &19141720 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *14853820
134
+ version_requirements: *19141720
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: thin
137
- requirement: &14853280 !ruby/object:Gem::Requirement
137
+ requirement: &19141140 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: 1.3.0
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *14853280
145
+ version_requirements: *19141140
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: activesupport
148
- requirement: &14852780 !ruby/object:Gem::Requirement
148
+ requirement: &19140660 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :runtime
155
155
  prerelease: false
156
- version_requirements: *14852780
156
+ version_requirements: *19140660
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: delorean
159
- requirement: &14852240 !ruby/object:Gem::Requirement
159
+ requirement: &19140000 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *14852240
167
+ version_requirements: *19140000
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: rspec
170
- requirement: &14851500 !ruby/object:Gem::Requirement
170
+ requirement: &19138360 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ~>
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: 2.8.0
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *14851500
178
+ version_requirements: *19138360
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: shoulda
181
- requirement: &14849980 !ruby/object:Gem::Requirement
181
+ requirement: &19137900 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ! '>='
@@ -186,7 +186,7 @@ dependencies:
186
186
  version: '0'
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *14849980
189
+ version_requirements: *19137900
190
190
  description: FnordMetric is a Ruby Event-Tracking gem on steroids
191
191
  email:
192
192
  - paul@paulasmuth.com
@@ -208,6 +208,7 @@ files:
208
208
  - lib/fnordmetric/cache.rb
209
209
  - lib/fnordmetric/context.rb
210
210
  - lib/fnordmetric/defaults.rb
211
+ - lib/fnordmetric/enterprise/compatibility_handler.rb
211
212
  - lib/fnordmetric/ext.rb
212
213
  - lib/fnordmetric/gauge.rb
213
214
  - lib/fnordmetric/gauge_calculations.rb