rack-instruments 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/rack/instruments.rb +11 -0
  2. metadata +1 -1
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-instruments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: