improve metrics gathered using in our traffic section

this also pulls out the middleware into its own home and inserts in front
This commit is contained in:
Sam
2015-02-05 16:08:52 +11:00
parent ebc2ad7c81
commit 08b790b3c2
14 changed files with 188 additions and 104 deletions

View File

@ -18,9 +18,9 @@ describe ApplicationRequest do
it 'can automatically flush' do
t1 = Time.now.utc.at_midnight
freeze_time(t1)
inc(:anon)
inc(:anon)
inc(:anon, autoflush: 3)
inc(:total)
inc(:total)
inc(:total, autoflush: 3)
ApplicationRequest.first.count.should == 3
end
@ -28,9 +28,9 @@ describe ApplicationRequest do
it 'flushes yesterdays results' do
t1 = Time.now.utc.at_midnight
freeze_time(t1)
inc(:anon)
inc(:total)
freeze_time(t1.tomorrow)
inc(:anon)
inc(:total)
ApplicationRequest.write_cache!
ApplicationRequest.count.should == 2
@ -49,15 +49,15 @@ describe ApplicationRequest do
time = Time.now.at_midnight
freeze_time(time)
3.times { inc(:anon) }
2.times { inc(:logged_in) }
4.times { inc(:crawler) }
3.times { inc(:total) }
2.times { inc(:success) }
4.times { inc(:redirect) }
ApplicationRequest.write_cache!
ApplicationRequest.anon.first.count.should == 3
ApplicationRequest.logged_in.first.count.should == 2
ApplicationRequest.crawler.first.count.should == 4
ApplicationRequest.total.first.count.should == 3
ApplicationRequest.success.first.count.should == 2
ApplicationRequest.redirect.first.count.should == 4
end
end