class Rack::Instrumentation
Public Class Methods
new(app)
click to toggle source
# File lib/rack/instrumentation.rb, line 7 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/instrumentation.rb, line 11 def call(env) begin header_metrics env time = Time.now response = @app.call(env) duration = (Time.now - time) * 1000.0 request_metrics response.first, duration, metric: 'rack.request' response rescue Exception => raised instrument 'rack.exception', 1, type: 'count' raise end end
Private Instance Methods
header_metrics(env)
click to toggle source
# File lib/rack/instrumentation.rb, line 30 def header_metrics(env) return unless env.keys.include?('HTTP_X_HEROKU_QUEUE_WAIT_TIME') instrument 'rack.heroku.queue.wait_time', env['HTTP_X_HEROKU_QUEUE_WAIT_TIME'].to_f, units: 'ms' end