Class: Takwimu::Rack

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Rack.



4
5
6
7
8
# File 'lib/takwimu/rack.rb', line 4

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



10
11
12
13
14
15
# File 'lib/takwimu/rack.rb', line 10

def call(env)
  env[TIMINGS] = {}
  env[GAUGES]  = []

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