fnordmetric 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,13 +9,21 @@ module FnordMetric
9
9
  def self.all(opts)
10
10
  range_opts = { :withscores => true }
11
11
  range_opts.merge!(:limit => [0,opts[:limit]]) if opts[:limit]
12
- opts[:redis].zrevrangebyscore(
12
+ events = opts[:redis].zrevrangebyscore(
13
13
  "#{opts[:namespace_prefix]}-timeline",
14
14
  '+inf', opts[:since]||'0',
15
15
  range_opts
16
- ).in_groups_of(2).map do |event_id, ts|
16
+ )
17
+
18
+ unless events.first.is_a?(Array)
19
+ events = events.in_groups_of(2).map do |event_id, ts|
20
+ [event_id, Float(ts)]
21
+ end
22
+ end
23
+
24
+ events.map do |event_id, ts|
17
25
  next if event_id.blank?
18
- find(event_id, opts).tap{ |e| e.time = ts }
26
+ find(event_id, opts).tap{ |e| e.time = "%.f" % ts }
19
27
  end
20
28
  end
21
29
 
@@ -47,12 +47,20 @@ module FnordMetric::GaugeCalculations
47
47
 
48
48
  def field_values_at(time, opts={}, &block)
49
49
  opts[:max_fields] ||= 50
50
- redis.zrevrange(
50
+ field_values = redis.zrevrange(
51
51
  tick_key(time),
52
52
  0, opts[:max_fields]-1,
53
53
  :withscores => true
54
- ).in_groups_of(2).map do |key, val|
55
- [key, calculate_value(val, time, opts, block)]
54
+ )
55
+
56
+ unless field_values.first.is_a?(Array)
57
+ field_values = field_values.in_groups_of(2).map do |key, val|
58
+ [key, Float(val)]
59
+ end
60
+ end
61
+
62
+ field_values.map do |key, val|
63
+ [key, calculate_value("%.f" % val, time, opts, block)]
56
64
  end
57
65
  end
58
66
 
@@ -27,8 +27,15 @@ class FnordMetric::Session
27
27
  set_key = "#{opts[:namespace_prefix]}-session"
28
28
  limit = (opts[:limit].try(:to_i)||0)-1
29
29
  session_ids = opts[:redis].zrevrange(set_key, 0, limit, :withscores => true)
30
- session_ids.in_groups_of(2).map do |session_key, ts|
31
- find(session_key, opts).tap{ |s| s.updated_at = ts }
30
+
31
+ unless session_ids.first.is_a?(Array)
32
+ session_ids = session_ids.in_groups_of(2).map do |session_id, ts|
33
+ [session_id, Float(ts)]
34
+ end
35
+ end
36
+
37
+ session_ids.map do |session_key, ts|
38
+ find(session_key, opts).tap{ |s| s.updated_at = "%.f" % ts }
32
39
  end
33
40
  end
34
41
 
@@ -7,7 +7,7 @@ class FnordMetric::TimelineWidget < FnordMetric::Widget
7
7
  :gauges => gauges.map(&:name),
8
8
  :gauge_titles => gauge_titles,
9
9
  :start_timestamp => ticks.first,
10
- :end_timestamp => ticks.last,
10
+ :end_timestamp => ticks.max,
11
11
  :autoupdate => (@opts[:autoupdate] || 60),
12
12
  :include_current => !!@opts[:include_current],
13
13
  :plot_style => (@opts[:plot_style] || 'line'),
@@ -1,3 +1,3 @@
1
1
  module FnordMetric
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
@@ -294,7 +294,7 @@ describe "increment three-dimensional gagues" do
294
294
  event = { :_time => @now }
295
295
  context.call(event, @redis_wrap)
296
296
  end
297
- @redis.zscore(gauge_key, "whoopwhoop").should == "13"
297
+ @redis.zscore(gauge_key, "whoopwhoop").to_f.should == 13.0
298
298
  @redis.get(gauge_key+"-count").should == "1"
299
299
  end
300
300
 
@@ -311,7 +311,7 @@ describe "increment three-dimensional gagues" do
311
311
  event = { :_time => @now }
312
312
  context.call(event, @redis_wrap)
313
313
  end
314
- @redis.zscore(gauge_key, "whoopwhoop").should == "5"
314
+ @redis.zscore(gauge_key, "whoopwhoop").to_f.should == 5.0
315
315
  @redis.get(gauge_key+"-count").should == "7"
316
316
  end
317
317
 
@@ -328,7 +328,7 @@ describe "increment three-dimensional gagues" do
328
328
  event = { :_time => @now, :myfield => "fnordybar" }
329
329
  context.call(event, @redis_wrap)
330
330
  end
331
- @redis.zscore(gauge_key, "fnordybar").should == "16"
331
+ @redis.zscore(gauge_key, "fnordybar").to_f.should == 16.0
332
332
  end
333
333
 
334
334
  it "should increment_unique a three-dim gauge" do
@@ -346,7 +346,7 @@ describe "increment three-dimensional gagues" do
346
346
  event = { :_time => @now, :_session_key => "mysesskey" }
347
347
  context.call(event, @redis_wrap)
348
348
  end
349
- @redis.zscore(gauge_key, "mykey").should == "84"
349
+ @redis.zscore(gauge_key, "mykey").to_f.should == 84.0
350
350
  @redis.get(gauge_key+"-sessions-count").should == "6"
351
351
  @redis.smembers(gauge_key+"-sessions").should == ["mysesskey"]
352
352
  end
@@ -367,7 +367,7 @@ describe "increment three-dimensional gagues" do
367
367
  event = { :_time => @now, :_session_key => "mysesskey" }
368
368
  context.call(event, @redis_wrap)
369
369
  end
370
- @redis.zscore(gauge_key, "otherkey").should == "54"
370
+ @redis.zscore(gauge_key, "otherkey").to_f.should == 54.0
371
371
  @redis.get(gauge_key+"-sessions-count").should == "5"
372
372
  @redis.smembers(gauge_key+"-sessions").should == ["mysesskey"]
373
373
  end
@@ -397,7 +397,7 @@ describe "increment three-dimensional gagues" do
397
397
  it "should set a value on a two-dim gauge" do
398
398
  gauge_key = "fnordmetrics-myns-gauge-mygauge_1463-10-695280200"
399
399
  @redis.zadd(gauge_key, 65, "asdasdkey")
400
- @redis.zscore(gauge_key, "asdasdkey").should == "65"
400
+ @redis.zscore(gauge_key, "asdasdkey").to_f.should == 65.0
401
401
  create_gauge_context({
402
402
  :key => "mygauge_1463",
403
403
  :three_dimensional => true,
@@ -408,7 +408,7 @@ describe "increment three-dimensional gagues" do
408
408
  event = { :_time => @now, :_session_key => "mysesskey" }
409
409
  context.call(event, @redis_wrap)
410
410
  end
411
- @redis.zscore(gauge_key, "asdasdkey").should == "23"
411
+ @redis.zscore(gauge_key, "asdasdkey").to_f.should == 23.0
412
412
  end
413
413
 
414
414
  end
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: 0.7.4
4
+ version: 0.7.5
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: 2012-05-07 00:00:00.000000000 Z
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
16
- requirement: &76649680 !ruby/object:Gem::Requirement
16
+ requirement: &72692540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.4.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *76649680
24
+ version_requirements: *72692540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sinatra
27
- requirement: &76649430 !ruby/object:Gem::Requirement
27
+ requirement: &72691750 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.2.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *76649430
35
+ version_requirements: *72691750
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: redis
38
- requirement: &76649170 !ruby/object:Gem::Requirement
38
+ requirement: &72691150 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.2.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *76649170
46
+ version_requirements: *72691150
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eventmachine
49
- requirement: &76648980 !ruby/object:Gem::Requirement
49
+ requirement: &72690410 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *76648980
57
+ version_requirements: *72690410
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: em-hiredis
60
- requirement: &76648650 !ruby/object:Gem::Requirement
60
+ requirement: &72687990 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *76648650
68
+ version_requirements: *72687990
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
- requirement: &76648380 !ruby/object:Gem::Requirement
71
+ requirement: &72686750 !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: *76648380
79
+ version_requirements: *72686750
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: i18n
82
- requirement: &76648090 !ruby/object:Gem::Requirement
82
+ requirement: &73268710 !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: *76648090
90
+ version_requirements: *73268710
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: haml
93
- requirement: &76665410 !ruby/object:Gem::Requirement
93
+ requirement: &73267810 !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: *76665410
101
+ version_requirements: *73267810
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rack
104
- requirement: &76665200 !ruby/object:Gem::Requirement
104
+ requirement: &73266740 !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: *76665200
112
+ version_requirements: *73266740
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rack-test
115
- requirement: &76664960 !ruby/object:Gem::Requirement
115
+ requirement: &73266240 !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: *76664960
123
+ version_requirements: *73266240
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: yajl-ruby
126
- requirement: &76664730 !ruby/object:Gem::Requirement
126
+ requirement: &73264900 !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: *76664730
134
+ version_requirements: *73264900
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: thin
137
- requirement: &76664460 !ruby/object:Gem::Requirement
137
+ requirement: &73264520 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *76664460
145
+ version_requirements: *73264520
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: activesupport
148
- requirement: &76664200 !ruby/object:Gem::Requirement
148
+ requirement: &73264010 !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: *76664200
156
+ version_requirements: *73264010
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: delorean
159
- requirement: &76663890 !ruby/object:Gem::Requirement
159
+ requirement: &73263370 !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: *76663890
167
+ version_requirements: *73263370
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: rspec
170
- requirement: &76663400 !ruby/object:Gem::Requirement
170
+ requirement: &73262880 !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: *76663400
178
+ version_requirements: *73262880
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: shoulda
181
- requirement: &76663190 !ruby/object:Gem::Requirement
181
+ requirement: &73262260 !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: *76663190
189
+ version_requirements: *73262260
190
190
  description: FnordMetric is a Ruby Event-Tracking gem on steroids
191
191
  email:
192
192
  - paul@paulasmuth.com
@@ -273,12 +273,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
273
273
  - - ! '>='
274
274
  - !ruby/object:Gem::Version
275
275
  version: '0'
276
+ segments:
277
+ - 0
278
+ hash: -854255121
276
279
  required_rubygems_version: !ruby/object:Gem::Requirement
277
280
  none: false
278
281
  requirements:
279
282
  - - ! '>='
280
283
  - !ruby/object:Gem::Version
281
284
  version: '0'
285
+ segments:
286
+ - 0
287
+ hash: -854255121
282
288
  requirements: []
283
289
  rubyforge_project:
284
290
  rubygems_version: 1.8.6
@@ -302,4 +308,3 @@ test_files:
302
308
  - spec/spec_helper.rb
303
309
  - spec/widget_spec.rb
304
310
  - spec/worker_spec.rb
305
- has_rdoc: