Module: Traxor::Rack::Middleware::QueueTime
- Defined in:
- lib/traxor/rack/middleware/queue_time.rb
Constant Summary collapse
- X_REQUEST_START =
'HTTP_X_REQUEST_START'
- EARLIEST_ACCEPTABLE_TIME =
any timestamps before this are thrown out and the parser will try again with a larger unit (2000/1/1 UTC)
Time.at(946_684_800).utc
- DIVISORS =
[1_000_000, 1_000, 1].freeze
Class Method Summary collapse
Class Method Details
.parse(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/traxor/rack/middleware/queue_time.rb', line 15 def self.parse(env) return unless env[X_REQUEST_START] value = env[X_REQUEST_START].to_s.sub(/t=/, '') DIVISORS.each do |divisor| time = Time.at(value.to_f / divisor).utc return time if time > EARLIEST_ACCEPTABLE_TIME end nil end |