rack-instruments 0.1.8 → 0.1.9

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 +10 -4
  2. metadata +1 -1
@@ -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
- Slides.log(:instrumentation,
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 }) do
26
- status, headers, response = @app.call(env)
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.id_generator = lambda { rand(36**8).to_s(36) }
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
 
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.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: