metriks-middleware 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/metriks/middleware.rb +7 -5
- data/metriks-middleware.gemspec +3 -2
- data/test/async_app_test.rb +6 -1
- data/test/sync_app_test.rb +6 -1
- metadata +18 -2
data/lib/metriks/middleware.rb
CHANGED
@@ -2,7 +2,7 @@ require 'metriks'
|
|
2
2
|
|
3
3
|
module Metriks
|
4
4
|
class Middleware
|
5
|
-
VERSION = '1.
|
5
|
+
VERSION = '1.3.0'
|
6
6
|
|
7
7
|
def initialize(app)
|
8
8
|
@app = app
|
@@ -10,7 +10,7 @@ module Metriks
|
|
10
10
|
|
11
11
|
def call(env)
|
12
12
|
time_response(env) do
|
13
|
-
|
13
|
+
record_heroku_status env
|
14
14
|
record_error_rate env
|
15
15
|
call_downstream env
|
16
16
|
end
|
@@ -28,12 +28,14 @@ module Metriks
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def record_heroku_status(env)
|
32
32
|
queue_wait = env['HTTP_X_HEROKU_QUEUE_WAIT_TIME']
|
33
33
|
queue_depth = env['HTTP_X_HEROKU_QUEUE_DEPTH']
|
34
|
+
dynos_in_use = env['HTTP_X_HEROKU_DYNOS_IN_USE']
|
34
35
|
|
35
|
-
Metriks.histogram("queue.wait")
|
36
|
-
Metriks.histogram("queue.depth").update(queue_depth.to_i)
|
36
|
+
Metriks.histogram("queue.wait") .update(queue_wait.to_i) if queue_wait
|
37
|
+
Metriks.histogram("queue.depth") .update(queue_depth.to_i) if queue_depth
|
38
|
+
Metriks.histogram("dynos.in_use").update(dynos_in_use.to_i) if dynos_in_use
|
37
39
|
end
|
38
40
|
|
39
41
|
def record_error_rate(env)
|
data/metriks-middleware.gemspec
CHANGED
@@ -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.
|
17
|
-
s.date = '2012-
|
16
|
+
s.version = '1.3.0'
|
17
|
+
s.date = '2012-12-11'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
## List your development dependencies here. Development dependencies are
|
45
45
|
## those that are only needed during development
|
46
46
|
s.add_development_dependency 'mocha', '~> 0.11.4'
|
47
|
+
s.add_development_dependency 'rake', '>= 0.9'
|
47
48
|
|
48
49
|
## Leave this section as-is. It will be automatically generated from the
|
49
50
|
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
data/test/async_app_test.rb
CHANGED
@@ -153,21 +153,26 @@ class AsyncAppTest < Test::Unit::TestCase
|
|
153
153
|
|
154
154
|
wait = Metriks.histogram('queue.wait').mean
|
155
155
|
depth = Metriks.histogram('queue.depth').mean
|
156
|
+
used = Metriks.histogram('dynos.in_use').mean
|
156
157
|
|
157
158
|
assert_equal 0, wait
|
158
159
|
assert_equal 0, depth
|
160
|
+
assert_equal 0, used
|
159
161
|
end
|
160
162
|
|
161
163
|
def test_records_heroku_queue_metrics
|
162
164
|
@env.merge! 'HTTP_X_HEROKU_QUEUE_WAIT_TIME' => '42',
|
163
|
-
'HTTP_X_HEROKU_QUEUE_DEPTH' => '24'
|
165
|
+
'HTTP_X_HEROKU_QUEUE_DEPTH' => '24',
|
166
|
+
'HTTP_X_HEROKU_DYNOS_IN_USE' => '3'
|
164
167
|
Metriks::Middleware.new(@downstream).call(@env)
|
165
168
|
@async_close.call
|
166
169
|
|
167
170
|
wait = Metriks.histogram('queue.wait').mean
|
168
171
|
depth = Metriks.histogram('queue.depth').mean
|
172
|
+
used = Metriks.histogram('dynos.in_use').mean
|
169
173
|
|
170
174
|
assert_equal 42, wait
|
171
175
|
assert_equal 24, depth
|
176
|
+
assert_equal 3, used
|
172
177
|
end
|
173
178
|
end
|
data/test/sync_app_test.rb
CHANGED
@@ -91,20 +91,25 @@ class SyncAppTest < Test::Unit::TestCase
|
|
91
91
|
|
92
92
|
wait = Metriks.histogram('queue.wait').mean
|
93
93
|
depth = Metriks.histogram('queue.depth').mean
|
94
|
+
used = Metriks.histogram('dynos.in_use').mean
|
94
95
|
|
95
96
|
assert_equal 0, wait
|
96
97
|
assert_equal 0, depth
|
98
|
+
assert_equal 0, used
|
97
99
|
end
|
98
100
|
|
99
101
|
def test_records_heroku_queue_metrics
|
100
102
|
@env.merge! 'HTTP_X_HEROKU_QUEUE_WAIT_TIME' => '42',
|
101
|
-
'HTTP_X_HEROKU_QUEUE_DEPTH' => '24'
|
103
|
+
'HTTP_X_HEROKU_QUEUE_DEPTH' => '24',
|
104
|
+
'HTTP_X_HEROKU_DYNOS_IN_USE' => '3'
|
102
105
|
Metriks::Middleware.new(@downstream).call(@env)
|
103
106
|
|
104
107
|
wait = Metriks.histogram('queue.wait').mean
|
105
108
|
depth = Metriks.histogram('queue.depth').mean
|
109
|
+
used = Metriks.histogram('dynos.in_use').mean
|
106
110
|
|
107
111
|
assert_equal 42, wait
|
108
112
|
assert_equal 24, depth
|
113
|
+
assert_equal 3, used
|
109
114
|
end
|
110
115
|
end
|
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.
|
4
|
+
version: 1.3.0
|
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-
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: metriks
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 0.11.4
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.9'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
46
62
|
description: Rack middleware to track throughput and response time with metriks.
|
47
63
|
email: larry@marburger.cc
|
48
64
|
executables: []
|