rack-instruments 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/instruments.rb +11 -0
- metadata +1 -1
data/lib/rack/instruments.rb
CHANGED
@@ -5,6 +5,11 @@ module Rack
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def call(env)
|
8
|
+
return @app.call(env) \
|
9
|
+
if self.class.ignore_extensions.any? { |ext|
|
10
|
+
env["REQUEST_PATH"] =~ /\.#{ext}$/
|
11
|
+
}
|
12
|
+
|
8
13
|
request_id = self.class.id_generator.call
|
9
14
|
request_start = Time.now
|
10
15
|
status, headers, response = nil, nil, nil
|
@@ -29,13 +34,19 @@ module Rack
|
|
29
34
|
module InstrumentsConfig
|
30
35
|
def self.extended(base)
|
31
36
|
base.id_generator = -> { rand(36**8).to_s(36) }
|
37
|
+
base.ignore_extensions = %w{css gif ico jpg js jpeg pdf png}
|
32
38
|
end
|
33
39
|
|
34
40
|
attr_accessor :id_generator
|
41
|
+
attr_accessor :ignore_extensions
|
35
42
|
|
36
43
|
def configure
|
37
44
|
yield self
|
38
45
|
end
|
46
|
+
|
47
|
+
def ignore_extensions
|
48
|
+
@ignore_extensions || []
|
49
|
+
end
|
39
50
|
end
|
40
51
|
Instruments.extend(InstrumentsConfig)
|
41
52
|
end
|