Class: Trashed::Rack

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

Instance Method Summary collapse

Constructor Details

#initialize(app, reporter, options = {}) ⇒ Rack

Returns a new instance of Rack.



7
8
9
10
11
# File 'lib/trashed/rack.rb', line 7

def initialize(app, reporter, options = {})
  @reporter = reporter
  @meters = Array(options.fetch(:meters, [ResourceUsage]))
  @app = build_instrumented_app(app, @meters)
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/trashed/rack.rb', line 13

def call(env)
  env[STATE]   = { :persistent => persistent_thread_state }
  env[TIMINGS] = {}
  env[GAUGES]  = []

  @app.call(env).tap { @reporter.report env }
end