metriks-middleware 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/lib/metriks/middleware.rb +1 -2
- data/lib/metriks/middleware/version.rb +5 -0
- data/metriks-middleware.gemspec +12 -21
- data/test/async_app_test.rb +32 -0
- data/test/sync_app_test.rb +22 -0
- data/test/test_helper.rb +1 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZjE1NTEyZGEyNjMxMDk4MGJmZmZhZWFmZTU2YzcwMzNlZTc2ZDUyYzdiODhh
|
10
|
-
NTJlZmFmMWFmNTEyYzlhNmQyMjZiNzEyZTM4ODBkYjlmMmJiYjMwZjRkM2Mx
|
11
|
-
NGU2NTE1MmNhOGEzMWJmMGU2YzVjMDU5NGY3N2E0ZDRjNDMwMDM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDMwMWFmZWY4NmNiZmY5OTYyN2FkZGRjMmE4MzZmNjU2YTVmZjIyM2Q4ZDA5
|
14
|
-
NjgwMWZhNDZmMTBlODkzOGFlMmViNGI5MjFmMGUxODhkZGYyZWZmMWQ1YWY0
|
15
|
-
NjViZGZiYzFkMDkxNDg4NTU1ZDRjMzg5NzQ1MjM0YmU4YzExN2Q=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 39f457cd2e5a084679e0dfeb4495bd4adaf92710
|
4
|
+
data.tar.gz: 2280424b3d0f4d8e5170c6b34752a786ca22d707
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8be5b9c8faf07e56dfc4789771822fe074b6ab64138fcbfde867b5c144ddcb5b574c5f56373dad896e0271d3a38f30160773af69f7022954db926e068b9cbbdb
|
7
|
+
data.tar.gz: 1d743a27716f543585fc199d3c6a0057c5bdbe4d120f877b4fd9b46edbdf9acb14795128bac4b749bd34da06bde1a3e1829e3eace50993b285bd11f8374f9da0
|
data/lib/metriks/middleware.rb
CHANGED
@@ -2,8 +2,6 @@ require 'metriks'
|
|
2
2
|
|
3
3
|
module Metriks
|
4
4
|
class Middleware
|
5
|
-
VERSION = '2.1.0'
|
6
|
-
|
7
5
|
REQUEST_DELAY = 'request_delay'
|
8
6
|
ERROR_RESPONSE = 'responses.error'
|
9
7
|
NOT_FOUND_RESPONSE = 'responses.not_found'
|
@@ -58,6 +56,7 @@ module Metriks
|
|
58
56
|
end
|
59
57
|
|
60
58
|
def record_staus_code(status)
|
59
|
+
status = status.to_i
|
61
60
|
if status >= 500
|
62
61
|
Metriks.meter(ERROR_RESPONSE).mark
|
63
62
|
elsif status == 404
|
data/metriks-middleware.gemspec
CHANGED
@@ -1,36 +1,27 @@
|
|
1
|
-
lib =
|
2
|
-
|
3
|
-
|
4
|
-
version = $1
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'metriks/middleware/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
|
10
|
-
spec.name = lib
|
11
|
-
spec.version = version
|
12
|
-
|
6
|
+
spec.name = 'metriks-middleware'
|
7
|
+
spec.version = Metriks::Middleware::VERSION
|
13
8
|
spec.summary = "Rack middleware for metriks"
|
14
9
|
spec.description = "Rack middleware to track throughput and response time with metriks."
|
15
|
-
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
spec.
|
19
|
-
spec.licenses = ['MIT']
|
10
|
+
spec.authors = ["Larry Marburger"]
|
11
|
+
spec.email = 'larry@marburger.cc'
|
12
|
+
spec.homepage = 'https://github.com/lmarburger/metriks-middleware'
|
13
|
+
spec.licenses = ['MIT']
|
20
14
|
|
21
15
|
spec.add_dependency 'metriks', '~> 0.9.9'
|
22
16
|
spec.add_development_dependency 'mocha', '~> 0.11.4'
|
23
17
|
spec.add_development_dependency 'rake', '>= 0.9'
|
24
18
|
|
25
19
|
spec.files = %w(Gemfile LICENSE README.md Rakefile)
|
26
|
-
spec.files << "
|
20
|
+
spec.files << "metriks-middleware.gemspec"
|
27
21
|
spec.files += Dir.glob("lib/**/*.rb")
|
28
22
|
spec.files += Dir.glob("test/**/*.rb")
|
29
23
|
spec.files += Dir.glob("script/*")
|
30
|
-
|
31
|
-
dev_null = File.exist?('/dev/null') ? '/dev/null' : 'NUL'
|
32
|
-
git_files = `git ls-files -z 2>#{dev_null}`
|
33
|
-
spec.files &= git_files.split("\0") if $?.success?
|
34
|
-
|
35
24
|
spec.test_files = Dir.glob("test/**/*.rb")
|
25
|
+
|
26
|
+
spec.required_rubygems_version = '>= 1.3.6'
|
36
27
|
end
|
data/test/async_app_test.rb
CHANGED
@@ -167,4 +167,36 @@ class AsyncAppTest < Test::Unit::TestCase
|
|
167
167
|
delay = Metriks.histogram('request_delay').mean
|
168
168
|
assert_equal 0, delay
|
169
169
|
end
|
170
|
+
|
171
|
+
def test_records_string_statuses
|
172
|
+
error_sync_app = lambda do |env| ['500', {}, ['']] end
|
173
|
+
error_async_app = lambda do |env|
|
174
|
+
env['async.callback'].call ['500', {}, ['']]
|
175
|
+
[-1, {}, ['']]
|
176
|
+
end
|
177
|
+
|
178
|
+
Metriks::Middleware.new(error_sync_app).call(@env.dup)
|
179
|
+
Metriks::Middleware.new(error_async_app).call(@env.dup)
|
180
|
+
|
181
|
+
errors = Metriks.meter('responses.error').count
|
182
|
+
assert_equal 2, errors
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_ignores_non_integer_statuses
|
186
|
+
error_sync_app = lambda do |env| ['fail', {}, ['']] end
|
187
|
+
error_async_app = lambda do |env|
|
188
|
+
env['async.callback'].call ['fail', {}, ['']]
|
189
|
+
[-1, {}, ['']]
|
190
|
+
end
|
191
|
+
|
192
|
+
Metriks::Middleware.new(error_sync_app).call(@env.dup)
|
193
|
+
Metriks::Middleware.new(error_async_app).call(@env.dup)
|
194
|
+
|
195
|
+
errors = Metriks.meter('responses.error').count
|
196
|
+
not_founds = Metriks.meter('responses.not_found').count
|
197
|
+
not_modifieds = Metriks.meter('responses.not_modified').count
|
198
|
+
assert_equal 0, errors
|
199
|
+
assert_equal 0, not_founds
|
200
|
+
assert_equal 0, not_modifieds
|
201
|
+
end
|
170
202
|
end
|
data/test/sync_app_test.rb
CHANGED
@@ -106,4 +106,26 @@ class SyncAppTest < Test::Unit::TestCase
|
|
106
106
|
delay = Metriks.histogram('request_delay').mean
|
107
107
|
assert_equal 0, delay
|
108
108
|
end
|
109
|
+
|
110
|
+
def test_records_string_statuses
|
111
|
+
error_app = lambda do |env| ['500', {}, ['']] end
|
112
|
+
2.times { Metriks::Middleware.new(error_app).call(@env) }
|
113
|
+
Metriks::Middleware.new(@downstream).call(@env)
|
114
|
+
|
115
|
+
errors = Metriks.meter('responses.error').count
|
116
|
+
assert_equal 2, errors
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_ignores_non_integer_statuses
|
120
|
+
error_app = lambda do |env| ['fail', {}, ['']] end
|
121
|
+
2.times { Metriks::Middleware.new(error_app).call(@env) }
|
122
|
+
Metriks::Middleware.new(@downstream).call(@env)
|
123
|
+
|
124
|
+
errors = Metriks.meter('responses.error').count
|
125
|
+
not_founds = Metriks.meter('responses.not_found').count
|
126
|
+
not_modifieds = Metriks.meter('responses.not_modified').count
|
127
|
+
assert_equal 0, errors
|
128
|
+
assert_equal 0, not_founds
|
129
|
+
assert_equal 0, not_modifieds
|
130
|
+
end
|
109
131
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metriks-middleware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Larry Marburger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metriks
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.9'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.9'
|
55
55
|
description: Rack middleware to track throughput and response time with metriks.
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
65
|
- metriks-middleware.gemspec
|
66
|
+
- lib/metriks/middleware/version.rb
|
66
67
|
- lib/metriks/middleware.rb
|
67
68
|
- test/async_app_test.rb
|
68
69
|
- test/sync_app_test.rb
|
@@ -79,19 +80,19 @@ require_paths:
|
|
79
80
|
- lib
|
80
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
82
|
requirements:
|
82
|
-
- -
|
83
|
+
- - '>='
|
83
84
|
- !ruby/object:Gem::Version
|
84
85
|
version: '0'
|
85
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
|
-
- -
|
88
|
+
- - '>='
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: 1.3.6
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.0.
|
93
|
+
rubygems_version: 2.0.2
|
93
94
|
signing_key:
|
94
|
-
specification_version:
|
95
|
+
specification_version: 4
|
95
96
|
summary: Rack middleware for metriks
|
96
97
|
test_files:
|
97
98
|
- test/async_app_test.rb
|