rack-instruments 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/instruments.rb +10 -4
- metadata +1 -1
data/lib/rack/instruments.rb
CHANGED
@@ -16,14 +16,18 @@ module Rack
|
|
16
16
|
# make ID of the request accessible to consumers down the stack
|
17
17
|
env["REQUEST_ID"] = request_id
|
18
18
|
|
19
|
-
|
19
|
+
data = {
|
20
20
|
:method => env["REQUEST_METHOD"],
|
21
21
|
:path => env["REQUEST_PATH"],
|
22
22
|
:ip => env["X-FORWARDED-FOR"] || env["HTTP_X_FORWARDED_FOR"] ||
|
23
23
|
env["REMOTE_ADDR"],
|
24
24
|
:id => request_id,
|
25
|
-
:status => lambda { status }
|
26
|
-
|
25
|
+
:status => lambda { status }
|
26
|
+
}
|
27
|
+
data.merge!(self.class.context) if self.class.context
|
28
|
+
|
29
|
+
Slides.log(:instrumentation, data) do
|
30
|
+
status, headers, response = @app.call(env)
|
27
31
|
end
|
28
32
|
|
29
33
|
[status, headers, response]
|
@@ -32,10 +36,12 @@ module Rack
|
|
32
36
|
|
33
37
|
module InstrumentsConfig
|
34
38
|
def self.extended(base)
|
35
|
-
base.
|
39
|
+
base.context = nil
|
40
|
+
base.id_generator = lambda { rand(36**8).to_s(36) }
|
36
41
|
base.ignore_extensions = %w{css gif ico jpg js jpeg pdf png}
|
37
42
|
end
|
38
43
|
|
44
|
+
attr_accessor :context
|
39
45
|
attr_accessor :id_generator
|
40
46
|
attr_accessor :ignore_extensions
|
41
47
|
|