metriks-middleware 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require 'metriks'
2
2
 
3
3
  module Metriks
4
4
  class Middleware
5
- VERSION = '1.2.1'
5
+ VERSION = '1.2.2'
6
6
 
7
7
  def initialize(app)
8
8
  @app = app
@@ -55,6 +55,8 @@ module Metriks
55
55
  Metriks.meter("responses.error").mark
56
56
  elsif status == 404
57
57
  Metriks.meter("responses.not_found").mark
58
+ elsif status == 304
59
+ Metriks.meter("responses.not_modified").mark
58
60
  end
59
61
  end
60
62
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'metriks-middleware'
16
- s.version = '1.2.1'
17
- s.date = '2012-09-25'
16
+ s.version = '1.2.2'
17
+ s.date = '2012-10-05'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
@@ -107,6 +107,29 @@ class AsyncAppTest < Test::Unit::TestCase
107
107
  assert_equal 2, not_founds
108
108
  end
109
109
 
110
+ def test_records_not_modified_responses
111
+ not_modified_sync_app = lambda do |env| [304, {}, ['']] end
112
+ not_modified_async_app = lambda do |env|
113
+ env['async.callback'].call [304, {}, ['']]
114
+ [-1, {}, ['']]
115
+ end
116
+
117
+ success_sync_app = lambda do |env| [200, {}, ['']] end
118
+ success_async_app = lambda do |env|
119
+ env['async.callback'].call [200, {}, ['']]
120
+ [-1, {}, ['']]
121
+ end
122
+
123
+ Metriks::Middleware.new(not_modified_sync_app).call(@env.dup)
124
+ Metriks::Middleware.new(not_modified_async_app).call(@env.dup)
125
+ Metriks::Middleware.new(success_sync_app).call(@env.dup)
126
+ Metriks::Middleware.new(success_async_app).call(@env.dup)
127
+
128
+ not_modifieds = Metriks.meter('responses.not_modified').count
129
+
130
+ assert_equal 2, not_modifieds
131
+ end
132
+
110
133
  def test_omits_queue_metrics
111
134
  Metriks::Middleware.new(@downstream).call(@env)
112
135
  @async_close.call
@@ -65,6 +65,16 @@ class SyncAppTest < Test::Unit::TestCase
65
65
  assert_equal 2, not_founds
66
66
  end
67
67
 
68
+ def test_records_not_modified_responses
69
+ not_modified_app = lambda do |env| [304, {}, ['']] end
70
+ 2.times { Metriks::Middleware.new(not_modified_app).call(@env) }
71
+ Metriks::Middleware.new(@downstream).call(@env)
72
+
73
+ not_modifieds = Metriks.meter('responses.not_modified').count
74
+
75
+ assert_equal 2, not_modifieds
76
+ end
77
+
68
78
  def test_omits_queue_metrics
69
79
  Metriks::Middleware.new(@downstream).call(@env)
70
80
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metriks-middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-25 00:00:00.000000000 Z
12
+ date: 2012-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: metriks