fnordmetric 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/Gemfile.lock +21 -0
- data/Procfile +1 -2
- data/VERSION +1 -1
- data/_spec/app_spec.rb +178 -0
- data/{spec → _spec}/cache_spec.rb +0 -0
- data/{spec → _spec}/combine_metric_spec.rb +0 -0
- data/{spec → _spec}/core_spec.rb +0 -0
- data/{spec → _spec}/count_metric_spec.rb +0 -0
- data/_spec/dashboard_spec.rb +67 -0
- data/_spec/event_spec.rb +46 -0
- data/{spec → _spec}/metric_spec.rb +0 -0
- data/{spec → _spec}/report_spec.rb +0 -0
- data/{spec → _spec}/sum_metric_spec.rb +0 -0
- data/_spec/widget_spec.rb +107 -0
- data/doc/import_dump.rb +26 -0
- data/em_runner.rb +33 -0
- data/fnordmetric.gemspec +59 -20
- data/haml/app.haml +26 -12
- data/lib/fnordmetric.rb +150 -15
- data/lib/fnordmetric/app.rb +70 -11
- data/lib/fnordmetric/cache.rb +4 -4
- data/lib/fnordmetric/context.rb +65 -0
- data/lib/fnordmetric/dashboard.rb +16 -12
- data/lib/fnordmetric/event.rb +65 -15
- data/lib/fnordmetric/gauge.rb +46 -0
- data/lib/fnordmetric/gauge_calculations.rb +43 -0
- data/lib/fnordmetric/gauge_modifiers.rb +43 -0
- data/lib/fnordmetric/inbound_stream.rb +66 -0
- data/lib/fnordmetric/logger.rb +38 -0
- data/lib/fnordmetric/namespace.rb +120 -0
- data/lib/fnordmetric/numbers_widget.rb +29 -11
- data/lib/fnordmetric/session.rb +131 -0
- data/lib/fnordmetric/standalone.rb +31 -0
- data/lib/fnordmetric/timeline_widget.rb +29 -9
- data/lib/fnordmetric/widget.rb +50 -45
- data/lib/fnordmetric/worker.rb +80 -0
- data/pub/fnordmetric/fnordmetric.css +76 -9
- data/pub/fnordmetric/fnordmetric.js +541 -42
- data/pub/raphael-min.js +8 -0
- data/pub/raphael-utils.js +221 -0
- data/readme.rdoc +172 -27
- data/server.rb +22 -0
- data/spec/app_spec.rb +359 -117
- data/spec/context_spec.rb +42 -0
- data/spec/dashboard_spec.rb +7 -47
- data/spec/event_spec.rb +114 -33
- data/spec/gauge_modifiers_spec.rb +276 -0
- data/spec/gauge_spec.rb +128 -0
- data/spec/namespace_spec.rb +104 -0
- data/spec/session_spec.rb +231 -0
- data/spec/spec_helper.rb +27 -4
- data/spec/widget_spec.rb +81 -75
- data/spec/worker_spec.rb +37 -0
- data/test_stream.sh +187 -0
- data/ulm_stats.rb +198 -0
- metadata +114 -35
- data/lib/fnordmetric/core.rb +0 -66
- data/lib/fnordmetric/engine.rb +0 -3
data/spec/app_spec.rb
CHANGED
@@ -1,178 +1,420 @@
|
|
1
1
|
require ::File.expand_path('../spec_helper.rb', __FILE__)
|
2
2
|
|
3
3
|
include Rack::Test::Methods
|
4
|
+
include FnordMetric
|
4
5
|
|
5
6
|
describe "app" do
|
6
7
|
|
7
|
-
before(:
|
8
|
-
|
8
|
+
before(:all) do
|
9
|
+
redis = Redis.new
|
10
|
+
@redis = RedisWrap.new(redis, false)
|
11
|
+
@opts = {
|
12
|
+
:redis_prefix => "fnordmetric",
|
13
|
+
:session_data_ttl => 120,
|
14
|
+
}
|
15
|
+
@now = Time.utc(1992,01,13,5,23,23).to_i
|
16
|
+
@namespace = Namespace.new(:foospace, @opts)
|
17
|
+
@redis_wrap = RedisWrap.new(@redis)
|
9
18
|
end
|
10
19
|
|
11
20
|
def app
|
12
|
-
@app ||= FnordMetric::App
|
21
|
+
@app ||= FnordMetric::App.new({
|
22
|
+
:foospace => proc{
|
23
|
+
widget 'Blubb', nil
|
24
|
+
}
|
25
|
+
}, @opts)
|
13
26
|
end
|
14
27
|
|
15
|
-
it "should redirect to the
|
28
|
+
it "should redirect to the first namespace" do
|
16
29
|
get "/"
|
17
30
|
last_response.status.should == 302
|
18
|
-
last_response.location.should == "http://example.org/
|
31
|
+
last_response.location.should == "http://example.org/foospace"
|
19
32
|
end
|
20
33
|
|
21
|
-
it "should render the
|
22
|
-
|
23
|
-
get "/dashboard/default"
|
24
|
-
last_response.status.should == 200
|
25
|
-
last_response.body.should include("Deine Mama")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should render the right dashboard" do
|
29
|
-
FnordMetric.dashboard("Deine Mama"){|dash|}
|
30
|
-
FnordMetric.dashboard("My Dashboard"){|dash|}
|
31
|
-
get "/dashboard/DeineMama"
|
32
|
-
last_response.status.should == 200
|
33
|
-
last_response.body.should include("Deine Mama")
|
34
|
-
get "/dashboard/MyDashboard"
|
34
|
+
it "should render the namespace" do
|
35
|
+
get "/foospace"
|
35
36
|
last_response.status.should == 200
|
36
|
-
last_response.body.should include("My Dashboard")
|
37
37
|
end
|
38
38
|
|
39
|
-
it "should
|
40
|
-
|
39
|
+
it "should render the dashboards" do
|
40
|
+
@app ||= FnordMetric::App.new({
|
41
|
+
:foospace => proc{
|
42
|
+
widget 'Blubb', nil
|
43
|
+
}
|
44
|
+
}, @opts)
|
45
|
+
get "/foospace"
|
41
46
|
last_response.status.should == 200
|
42
|
-
|
43
|
-
FnordMetric::Event.last.fnord.should == "foobar"
|
47
|
+
last_response.body.should include("Blubb")
|
44
48
|
end
|
45
49
|
|
46
|
-
it "should
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
FnordMetric::Event.last.time.should == my_time
|
50
|
+
it "should render the dashboards" do
|
51
|
+
@app ||= FnordMetric::App.new({
|
52
|
+
:foospace => proc{
|
53
|
+
widget 'Blubb', nil
|
54
|
+
widget 'Fnord', nil
|
55
|
+
}
|
56
|
+
}, @opts)
|
57
|
+
get "/foospace"
|
58
|
+
last_response.status.should == 200
|
59
|
+
last_response.body.should include("Blubb")
|
60
|
+
last_response.body.should include("Fnord")
|
58
61
|
end
|
59
62
|
|
60
|
-
|
61
|
-
post "/events", :type => "myevent", :blubb => "123"
|
62
|
-
last_response.status.should == 200
|
63
|
-
FnordMetric::Event.last.type.should == "myevent"
|
64
|
-
FnordMetric::Event.last.blubb.should == 123
|
65
|
-
end
|
63
|
+
describe "sessions api" do
|
66
64
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
FnordMetric::Event.last.type.should == "myevent"
|
71
|
-
FnordMetric::Event.last.blubb.should == 42.23
|
72
|
-
end
|
65
|
+
before(:each) do
|
66
|
+
@redis.keys("fnordmetric-foospace*").each { |k| @redis.del(k) }
|
67
|
+
end
|
73
68
|
|
69
|
+
it "should render a list of all active sessions" do
|
70
|
+
@namespace.ready!(@redis_wrap).announce(
|
71
|
+
:_time => Time.now.to_i,
|
72
|
+
:_type => "foobar",
|
73
|
+
:_session => "sess213"
|
74
|
+
)
|
75
|
+
get "/foospace/sessions"
|
76
|
+
JSON.parse(last_response.body).should have_key("sessions")
|
77
|
+
JSON.parse(last_response.body)["sessions"].length.should == 1
|
78
|
+
end
|
74
79
|
|
75
|
-
|
80
|
+
it "should render a list of all active sessions with timestamps" do
|
81
|
+
@namespace.ready!(@redis_wrap).announce(
|
82
|
+
:_time => @now-5,
|
83
|
+
:_type => "foobar",
|
84
|
+
:_session => "sess213"
|
85
|
+
)
|
86
|
+
get "/foospace/sessions"
|
87
|
+
sess = JSON.parse(last_response.body)["sessions"].first
|
88
|
+
sess["_updated_at"].should == (@now-5).to_s
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should render a list of all active sessions with usernames" do
|
92
|
+
@namespace.ready!(@redis_wrap).announce(
|
93
|
+
:_time => @now,
|
94
|
+
:_type => "_set_name",
|
95
|
+
:_session => "sess213",
|
96
|
+
:name => "Hans Peter"
|
97
|
+
)
|
98
|
+
get "/foospace/sessions"
|
99
|
+
sess = JSON.parse(last_response.body)["sessions"].first
|
100
|
+
sess["_name"].should == "Hans Peter"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should render a list of all active sessions with user pictures" do
|
104
|
+
@namespace.ready!(@redis_wrap).announce(
|
105
|
+
:_time => @now,
|
106
|
+
:_type => "_set_picture",
|
107
|
+
:_session => "sess213",
|
108
|
+
:url => "http://myhost.com/mypic.jpg"
|
109
|
+
)
|
110
|
+
get "/foospace/sessions"
|
111
|
+
sess = JSON.parse(last_response.body)["sessions"].first
|
112
|
+
sess["_picture"].should == "http://myhost.com/mypic.jpg"
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should render a list of all active sessions with hashed keys" do
|
116
|
+
@namespace.ready!(@redis_wrap).announce(
|
117
|
+
:_time => @now-5,
|
118
|
+
:_type => "foobar",
|
119
|
+
:_session => "sess133"
|
120
|
+
)
|
121
|
+
get "/foospace/sessions"
|
122
|
+
sess = JSON.parse(last_response.body)["sessions"].first
|
123
|
+
sess["session_key"].should == Digest::MD5.hexdigest("sess133")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should not render more than 100 sessions at once" do
|
127
|
+
123.times do |n|
|
128
|
+
@namespace.ready!(@redis_wrap).announce(
|
129
|
+
:_time => Time.now.to_i,
|
130
|
+
:_type => "foobar",
|
131
|
+
:_session => "sess213-#{n}"
|
132
|
+
)
|
133
|
+
end
|
134
|
+
get "/foospace/sessions"
|
135
|
+
JSON.parse(last_response.body).should have_key("sessions")
|
136
|
+
JSON.parse(last_response.body)["sessions"].length.should == 100
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should render sessions ordered by last_updated_at" do
|
140
|
+
context = @namespace.ready!(@redis_wrap)
|
141
|
+
context.announce(
|
142
|
+
:_time => Time.now.to_i,
|
143
|
+
:_type => "foobar",
|
144
|
+
:_session => "sessfoo"
|
145
|
+
)
|
146
|
+
context.announce(
|
147
|
+
:_time => Time.now.to_i-23,
|
148
|
+
:_type => "foobar",
|
149
|
+
:_session => "sessbar"
|
150
|
+
)
|
151
|
+
context.announce(
|
152
|
+
:_time => Time.now.to_i-5,
|
153
|
+
:_type => "foobar",
|
154
|
+
:_session => "sessfnord"
|
155
|
+
)
|
156
|
+
get "/foospace/sessions"
|
157
|
+
sessions = JSON.parse(last_response.body)["sessions"]
|
158
|
+
sessions.length.should == 3
|
159
|
+
sessions[0]["session_key"].should == Digest::MD5.hexdigest("sessfoo")
|
160
|
+
sessions[1]["session_key"].should == Digest::MD5.hexdigest("sessfnord")
|
161
|
+
sessions[2]["session_key"].should == Digest::MD5.hexdigest("sessbar")
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "events api: rendering events" do
|
76
167
|
|
77
168
|
before(:each) do
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
169
|
+
@redis.keys("fnordmetric-foospace*").each { |k| @redis.del(k) }
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should render a list of all events" do
|
173
|
+
@namespace.ready!(@redis_wrap).announce(
|
174
|
+
:_eid => "sdkjgh9sd8f",
|
175
|
+
:_time => Time.now.to_i,
|
176
|
+
:_type => "foobar!!!"
|
177
|
+
)
|
178
|
+
get "/foospace/events"
|
179
|
+
JSON.parse(last_response.body).should have_key("events")
|
180
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
89
181
|
end
|
90
182
|
|
91
|
-
it "should
|
92
|
-
|
93
|
-
|
183
|
+
it "should render a list of all events including event-times" do
|
184
|
+
@namespace.ready!(@redis_wrap).announce(
|
185
|
+
:_eid => "sdkjgh9sd8f",
|
186
|
+
:_time => @now-23,
|
187
|
+
:_type => "foobar!!!"
|
188
|
+
)
|
189
|
+
get "/foospace/events"
|
190
|
+
JSON.parse(last_response.body).should have_key("events")
|
191
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
192
|
+
JSON.parse(last_response.body)["events"].first["_time"].to_i.should == @now-23
|
94
193
|
end
|
95
194
|
|
96
|
-
it "should
|
97
|
-
|
98
|
-
|
195
|
+
it "should render a list of all events including event-ids" do
|
196
|
+
@namespace.ready!(@redis_wrap).announce(
|
197
|
+
:_eid => "sdkjgh9sd8f",
|
198
|
+
:_time => Time.now.to_i,
|
199
|
+
:_type => "foobar!!!"
|
200
|
+
)
|
201
|
+
get "/foospace/events"
|
202
|
+
JSON.parse(last_response.body).should have_key("events")
|
203
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
204
|
+
JSON.parse(last_response.body)["events"].first["_eid"].should == "sdkjgh9sd8f"
|
99
205
|
end
|
100
206
|
|
101
|
-
it "should return the right answer for: /metric/:name?at=timestamp-timstamp" do
|
102
|
-
get "/metric/my_event_count", :at => "#{30.hours.ago.to_i}-#{20.hours.ago.to_i}"
|
103
|
-
JSON.parse(last_response.body)["value"].to_i.should == 3
|
104
|
-
end
|
105
207
|
|
106
|
-
it "should
|
107
|
-
|
108
|
-
|
208
|
+
it "should render a list of all events including event-types" do
|
209
|
+
create_event("sdkjgh9sd8f", {
|
210
|
+
:_eid => "sdkjgh9sd8f",
|
211
|
+
:_time => Time.now.to_i,
|
212
|
+
:_type => "foobar!!!"
|
213
|
+
})
|
214
|
+
get "/foospace/events"
|
215
|
+
JSON.parse(last_response.body).should have_key("events")
|
216
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
217
|
+
JSON.parse(last_response.body)["events"].first["_type"].should == "foobar!!!"
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should render a list of all events including _session-data" do
|
221
|
+
create_event("65785678634", {
|
222
|
+
:_eid => "65785678634",
|
223
|
+
:_time => @now-23,
|
224
|
+
:_type => "foobar!!!",
|
225
|
+
:_session => "blubb123"
|
226
|
+
})
|
227
|
+
get "/foospace/events"
|
228
|
+
JSON.parse(last_response.body).should have_key("events")
|
229
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
230
|
+
JSON.parse(last_response.body)["events"].first["_session"].should == "blubb123"
|
109
231
|
end
|
110
232
|
|
111
|
-
it "should
|
112
|
-
|
113
|
-
|
114
|
-
|
233
|
+
it "should render a list of all events including _session-data" do
|
234
|
+
create_event("4234234634", {
|
235
|
+
:_eid => "4234234634",
|
236
|
+
:_time => @now-23,
|
237
|
+
:_type => "foobar!!!",
|
238
|
+
:_session => "blubb123",
|
239
|
+
:fnord => "yeah"
|
240
|
+
})
|
241
|
+
get "/foospace/events"
|
242
|
+
JSON.parse(last_response.body).should have_key("events")
|
243
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
244
|
+
blubb123_md5 = "e5fa475b26873af5ec6c77668f9975a5"
|
245
|
+
JSON.parse(last_response.body)["events"].first["_session_key"].should == blubb123_md5
|
115
246
|
end
|
116
247
|
|
117
|
-
it "should
|
118
|
-
|
119
|
-
|
120
|
-
|
248
|
+
it "should render a list of all events in the correct chronological order" do
|
249
|
+
create_event("daasdasd", {
|
250
|
+
:_eid => "daasdasd",
|
251
|
+
:_time => @now-23,
|
252
|
+
:_type => "foobar!!!"
|
253
|
+
})
|
254
|
+
create_event("345345345", {
|
255
|
+
:_eid => "345345345",
|
256
|
+
:_time => @now-5,
|
257
|
+
:_type => "foobar!!!"
|
258
|
+
})
|
259
|
+
create_event("sdygsygsdg", {
|
260
|
+
:_eid => "sdygsygsdg",
|
261
|
+
:_time => @now-16,
|
262
|
+
:_type => "foobar!!!"
|
263
|
+
})
|
264
|
+
get "/foospace/events"
|
265
|
+
JSON.parse(last_response.body).should have_key("events")
|
266
|
+
JSON.parse(last_response.body)["events"].length.should == 3
|
267
|
+
JSON.parse(last_response.body)["events"][0]["_eid"].should == "345345345"
|
268
|
+
JSON.parse(last_response.body)["events"][1]["_eid"].should == "sdygsygsdg"
|
269
|
+
JSON.parse(last_response.body)["events"][2]["_eid"].should == "daasdasd"
|
121
270
|
end
|
122
271
|
|
123
|
-
it "should
|
124
|
-
|
125
|
-
|
126
|
-
|
272
|
+
it "should not render more than 100 events at a time" do
|
273
|
+
120.times do |n|
|
274
|
+
create_event("sdygsygsdg-#{n}", {
|
275
|
+
:_eid => "sdygsygsdg-#{n}",
|
276
|
+
:_time => @now-16,
|
277
|
+
:_type => "foobar!!!"
|
278
|
+
})
|
279
|
+
end
|
280
|
+
get "/foospace/events"
|
281
|
+
JSON.parse(last_response.body).should have_key("events")
|
282
|
+
JSON.parse(last_response.body)["events"].length.should == 100
|
127
283
|
end
|
128
284
|
|
129
|
-
it "should
|
130
|
-
|
131
|
-
|
132
|
-
|
285
|
+
it "should render all events since a time, not including events at that exact time" do
|
286
|
+
create_event("daasdasd", {
|
287
|
+
:_eid => "daasdasd",
|
288
|
+
:_time => @now-23,
|
289
|
+
:_type => "foobar!!!"
|
290
|
+
})
|
291
|
+
create_event("345345345", {
|
292
|
+
:_eid => "345345345",
|
293
|
+
:_time => @now-5,
|
294
|
+
:_type => "foobar!!!"
|
295
|
+
})
|
296
|
+
create_event("sdygsygsdg", {
|
297
|
+
:_eid => "sdygsygsdg",
|
298
|
+
:_time => @now-16,
|
299
|
+
:_type => "foobar!!!"
|
300
|
+
})
|
301
|
+
get "/foospace/events?since=#{@now-24}"
|
302
|
+
JSON.parse(last_response.body)["events"].length.should == 3
|
303
|
+
get "/foospace/events?since=#{@now-17}"
|
304
|
+
JSON.parse(last_response.body)["events"].length.should == 2
|
305
|
+
get "/foospace/events?since=#{@now-16}"
|
306
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
307
|
+
get "/foospace/events?since=#{@now-2}"
|
308
|
+
JSON.parse(last_response.body)["events"].length.should == 0
|
133
309
|
end
|
134
310
|
|
135
|
-
it "should
|
136
|
-
|
137
|
-
|
138
|
-
|
311
|
+
it "should render all events for a single event type" do
|
312
|
+
@namespace.ready!(@redis_wrap).announce(
|
313
|
+
:_type => "fn0rd",
|
314
|
+
:_time => @now,
|
315
|
+
:_eid => "124234"
|
316
|
+
)
|
317
|
+
@namespace.ready!(@redis_wrap).announce(
|
318
|
+
:_type => "f00bar",
|
319
|
+
:_time => @now,
|
320
|
+
:_eid => "12235234"
|
321
|
+
)
|
322
|
+
@namespace.ready!(@redis_wrap).announce(
|
323
|
+
:_type => "fn0rd",
|
324
|
+
:_time => @now,
|
325
|
+
:_eid => "124234234"
|
326
|
+
)
|
327
|
+
get "/foospace/events?type=fn0rd"
|
328
|
+
JSON.parse(last_response.body)["events"].length.should == 2
|
329
|
+
get "/foospace/events?type=f00bar"
|
330
|
+
JSON.parse(last_response.body)["events"].length.should == 1
|
139
331
|
end
|
140
332
|
|
141
|
-
it "should
|
142
|
-
|
143
|
-
|
333
|
+
it "should render a list of event types" do
|
334
|
+
@namespace.ready!(@redis_wrap).announce(
|
335
|
+
:_type => "fn0rd",
|
336
|
+
:_time => @now,
|
337
|
+
:_eid => "124234"
|
338
|
+
)
|
339
|
+
@namespace.ready!(@redis_wrap).announce(
|
340
|
+
:_type => "f00bar",
|
341
|
+
:_time => @now,
|
342
|
+
:_eid => "12235234"
|
343
|
+
)
|
344
|
+
@namespace.ready!(@redis_wrap).announce(
|
345
|
+
:_type => "fn0rd",
|
346
|
+
:_time => @now,
|
347
|
+
:_eid => "124234234"
|
348
|
+
)
|
349
|
+
get "/foospace/event_types"
|
350
|
+
JSON.parse(last_response.body)["types"].length.should == 2
|
351
|
+
JSON.parse(last_response.body)["types"].should include("fn0rd")
|
352
|
+
JSON.parse(last_response.body)["types"].should include("f00bar")
|
144
353
|
end
|
145
354
|
|
146
|
-
it "should
|
147
|
-
|
148
|
-
|
149
|
-
|
355
|
+
it "should render all events for a single session"
|
356
|
+
|
357
|
+
it "should render all events for a single session since a unix timestamp"
|
358
|
+
|
359
|
+
it "should render all events for a single session, but not more than 100"
|
360
|
+
|
361
|
+
def create_event(event_id, event_data)
|
362
|
+
@redis_wrap.zadd(@namespace.key_prefix(:timeline), event_data.delete(:_time), event_id)
|
363
|
+
@redis_wrap.set("fnordmetric-event-#{event_id}", event_data.to_json)
|
150
364
|
end
|
151
365
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
366
|
+
end
|
367
|
+
|
368
|
+
describe "events api: creating events" do
|
369
|
+
|
370
|
+
it "should track an event without auth" do
|
371
|
+
pending("fix this")
|
372
|
+
#post "/events", :type => "myevent", :fnord => "foobar"
|
373
|
+
#last_response.status.should == 200
|
374
|
+
#FnordMetric::Event.last.type.should == "myevent"
|
375
|
+
#FnordMetric::Event.last.fnord.should == "foobar"
|
156
376
|
end
|
157
377
|
|
158
|
-
it "should return
|
159
|
-
|
160
|
-
|
161
|
-
|
378
|
+
it "should return 400 if no type is provided" do
|
379
|
+
pending("fix this")
|
380
|
+
#post "/events", :fnord => "foobar"
|
381
|
+
#last_response.status.should == 400
|
382
|
+
#last_response.body.should == "please specify the event_type"
|
162
383
|
end
|
163
384
|
|
164
|
-
it "should
|
165
|
-
|
166
|
-
|
167
|
-
|
385
|
+
it "should track an event in the past" do
|
386
|
+
pending("fix this")
|
387
|
+
#my_time = (Time.now-3.years).to_i
|
388
|
+
#post "/events", :type => "myevent", :time => my_time
|
389
|
+
#last_response.status.should == 200
|
390
|
+
#FnordMetric::Event.last.type.should == "myevent"
|
391
|
+
#FnordMetric::Event.last.time.should == my_time
|
168
392
|
end
|
169
393
|
|
170
|
-
it "should
|
171
|
-
|
172
|
-
|
173
|
-
|
394
|
+
it "should track an event with integer data" do
|
395
|
+
pending("fix this")
|
396
|
+
#post "/events", :type => "myevent", :blubb => "123"
|
397
|
+
#last_response.status.should == 200
|
398
|
+
#FnordMetric::Event.last.type.should == "myevent"
|
399
|
+
#FnordMetric::Event.last.blubb.should == 123
|
174
400
|
end
|
401
|
+
|
402
|
+
it "should track an event with float data" do
|
403
|
+
pending("fix this")
|
404
|
+
#post "/events", :type => "myevent", :blubb => "42.23"
|
405
|
+
#last_response.status.should == 200
|
406
|
+
#FnordMetric::Event.last.type.should == "myevent"
|
407
|
+
#FnordMetric::Event.last.blubb.should == 42.23
|
408
|
+
end
|
409
|
+
|
410
|
+
|
175
411
|
|
412
|
+
|
413
|
+
end
|
414
|
+
|
415
|
+
describe "metrics api" do
|
416
|
+
# copy from _spec/app_spec.rb ?
|
176
417
|
end
|
177
|
-
|
418
|
+
|
419
|
+
|
178
420
|
end
|