rack-instruments 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rack/instruments.rb +11 -15
  2. metadata +2 -2
@@ -9,24 +9,20 @@ module Rack
9
9
  def call(env)
10
10
  request_id = UUIDTools::UUID.timestamp_create.to_s
11
11
  request_start = Time.now
12
- Scrolls.log :instrumentation,
13
- at: "start",
14
- method: env["REQUEST_METHOD"],
15
- route: env["REQUEST_PATH"],
16
- ip: env["REMOTE_ADDR"],
17
- id: request_id
12
+ status, headers, response = nil, nil, nil
18
13
 
14
+ # make ID of the request accessible to consumers down the stack
19
15
  env["REQUEST_ID"] = request_id
20
- status, headers, response = @app.call(env)
21
16
 
22
- Scrolls.log :instrumentation,
23
- at: "finish",
24
- method: env["REQUEST_METHOD"],
25
- route: env["REQUEST_PATH"],
26
- ip: env["REMOTE_ADDR"],
27
- status: status,
28
- elapsed: "#{Integer((Time.now - request_start) * 1000)}ms",
29
- id: request_id
17
+ Scrolls.log(:instrumentation,
18
+ method: env["REQUEST_METHOD"],
19
+ path: env["REQUEST_PATH"],
20
+ ip: env["X-FORWARDED-FOR"] || env["HTTP_X_FORWARDED_FOR"] ||
21
+ env["REMOTE_ADDR"],
22
+ id: request_id,
23
+ status: -> { status }) do
24
+ status, headers, response = @app.call(env)
25
+ end
30
26
 
31
27
  [status, headers, response]
32
28
  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.3
4
+ version: 0.1.4
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-06-10 00:00:00.000000000 Z
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: scrolls-minimal