Class: Rack::Latency::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/latency/reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, logger = nil) ⇒ Reporter

Returns a new instance of Reporter.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rack/latency/reporter.rb', line 7

def initialize(app, logger = nil)
  @app = app
  @logger = logger || ::Logger.new($stdout)

  interval = (Rack::Latency.get_wait).to_i
  if defined?(Rails)
    start(interval) if Rack::Latency.get_environments.include?(Rails.env.to_sym)
  else
    start(interval) if Rack::Latency.get_environments.include(ENV["RACK_ENV"].to_sym)
  end
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
# File 'lib/rack/latency/reporter.rb', line 19

def call(env)
  status, headers, body = @app.call(env)
  [status, headers, body]
end