class Rack::Perf
Constants
- HIDDEN_READABLE_FIELDS
- VERSION
Public Class Methods
new(stack, api_key, debug = false)
click to toggle source
# File lib/rack/perf.rb, line 14 def initialize(stack, api_key, debug = false) @stack = stack @api_key = api_key @debug = debug end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/perf.rb, line 20 def call(env) @env = env # log the current time now before the request starts performance_tracker = PerformanceTracker.new performance_tracker.start # run the current request request = Rack::Request.new(env) status, headers, body = stack.call(env) # log the end time of the request performance_tracker.end # normalize url normalized_path = NormalizePath.new(request) # send it up as long as we don't get nil, this helps # in cases when we intercept asset urls that don't # really matter if normalized_path.path? send_data = SendDataToPerf.new send_data.api_key = @api_key send_data.ip_addr = DetermineIPAddress.new(request).ip_address send_data.request_method = request.request_method send_data.request_url = request.url send_data.normalized_uri = normalized_path.path send_data.status_code = status send_data.time_in_millis = performance_tracker.time send_data.perform! end # send back intended data [status, headers, body] end