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
# 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

  @logger.info "-> rack-latency starting in interval mode (#{interval}s)"
  Thread.new { report(interval) }
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
# File 'lib/rack/latency/reporter.rb', line 17

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