rack-instruments 0.1.1 → 0.1.2

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 +21 -5
  2. metadata +17 -1
@@ -1,3 +1,5 @@
1
+ require "uuidtools"
2
+
1
3
  module Rack
2
4
  class Instruments
3
5
  def initialize(app)
@@ -5,13 +7,27 @@ module Rack
5
7
  end
6
8
 
7
9
  def call(env)
8
- @start_request = Time.now
9
- status, headers, response = @app.call(env)
10
+ request_id = UUIDTools::UUID.timestamp_create.to_s
11
+ request_start = Time.now
10
12
  Scrolls.log :instrumentation,
13
+ at: start,
11
14
  method: env["REQUEST_METHOD"],
12
- route: env["REQUEST_PATH"],
13
- elapsed: "#{Integer((Time.now - @start_request) * 1000)}ms",
14
- ip: env["REMOTE_ADDR"]
15
+ route: env["REQUEST_PATH"],
16
+ ip: env["REMOTE_ADDR"],
17
+ id: request_id
18
+
19
+ env["REQUEST_ID"] = request_id
20
+ status, headers, response = @app.call(env)
21
+
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
30
+
15
31
  [status, headers, response]
16
32
  end
17
33
  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.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: uuidtools
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.1.2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.1.2
30
46
  description:
31
47
  email: brandur@mutelight.org
32
48
  executables: []