traxor 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc441e258d65128f73742b99a5dd49d1f0ad654528189e34825b9b2fedca49a2
4
- data.tar.gz: 70f8d1a29de23867a061e661c7eba14dd96de6c1ec8013120e82f059c13242a5
3
+ metadata.gz: de2e0c72345192d52a355f1d1092b59cd2652cf3d2e3611238a525362f700ae2
4
+ data.tar.gz: 733a91fe1e2813188b79fc6bab6853a8cc1397d35c1a4d0ef9acbc64930a7fc2
5
5
  SHA512:
6
- metadata.gz: cd980ca09c39cb63998bb4071d6b36b1eaf2b2be84a066ce37ee484d4e2f70f797f5752e1b1e4821513fff6baf4cb3851df67bcda94f65a2d567b1a8f18225b6
7
- data.tar.gz: ed7f010baf4cfd0642b07fa8987267da6f0f5f52a64f223f603abb90a7a419b7e73df6a38471e089526ed6c0a07713e3f4be6c6a19bdc340fde3b664df72b9a4
6
+ metadata.gz: 8c1818372a18ed552085161498b68e0477bb96e0f959eea5a8a89a56c7e293d6962f5c909964c4d337973f35e62046b173d138f09905fd9ed9385a7cafab6226
7
+ data.tar.gz: 6f247f75df7d0eee65ef8681df0415abf8ec3b7006247c7b1faf23375e6b7659def46662e6a8f1faf57c08e6b0e2fa492845341b5662d026d7e610ae7e44f586
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- traxor (0.1.9)
4
+ traxor (0.1.10)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -2,6 +2,12 @@ module Traxor
2
2
  module Rack
3
3
  module Middleware
4
4
  class Pre
5
+ # any timestamps before this are thrown out and the parser
6
+ # will try again with a larger unit (2000/1/1 UTC)
7
+ EARLIEST_ACCEPTABLE_TIME = Time.at(946684800)
8
+
9
+ DIVISORS = [1_000_000, 1_000, 1]
10
+
5
11
  def initialize(app)
6
12
  @app = app
7
13
  end
@@ -9,9 +15,9 @@ module Traxor
9
15
  def call(env)
10
16
  env['traxor.rack.middleware.pre_middleware_start'] = Time.now.to_f
11
17
  queue_duration = nil
12
- request_start_ms = env['HTTP_X_REQUEST_START']
13
- if request_start_ms
14
- queue_duration = (env['traxor.rack.middleware.pre_middleware_start'].to_f * 1_000) - request_start_ms.to_f
18
+ request_start = env['HTTP_X_REQUEST_START']
19
+ if request_start
20
+ queue_duration = (env['traxor.rack.middleware.pre_middleware_start'].to_f - parse_request_queue(request_start).to_f) * 1_000
15
21
  end
16
22
  status, headers, body = @app.call(env)
17
23
  env['traxor.rack.middleware.post_middleware_end'] = Time.now.to_f
@@ -52,6 +58,21 @@ module Traxor
52
58
 
53
59
  [status, headers, body]
54
60
  end
61
+
62
+ def parse_request_queue(string)
63
+ DIVISORS.each do |divisor|
64
+ begin
65
+ t = Time.at(string.to_f / divisor)
66
+ return t if t > EARLIEST_ACCEPTABLE_TIME
67
+ rescue RangeError
68
+ # On Ruby versions built with a 32-bit time_t, attempting to
69
+ # instantiate a Time object in the far future raises a RangeError,
70
+ # in which case we know we've chosen the wrong divisor.
71
+ end
72
+ end
73
+
74
+ nil
75
+ end
55
76
  end
56
77
  end
57
78
  end
@@ -1,3 +1,3 @@
1
1
  module Traxor
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.1.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traxor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hansen