class Rack::Heroku::Profiler

Appends a X-Heroku-Queue-Wait header to the response

Constants

REQ_HEADER
RES_HEADER
VALS_RANGE

Public Class Methods

new(app) click to toggle source
# File lib/rack/heroku/profiler.rb, line 7
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/heroku/profiler.rb, line 11
def call(env)
  ms = time_since env[REQ_HEADER]
  status, headers, body = @app.call(env)
  headers.update RES_HEADER => ms.to_s if ms && VALS_RANGE.include?(ms)

  [status, headers, body]
end

Private Instance Methods

time_since(start) click to toggle source
# File lib/rack/heroku/profiler.rb, line 21
def time_since(start)
  (Time.now.to_f * 1_000).to_i - start.to_i if start
end