Class: Speedshop::Cloudwatch::Rack

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rack

Returns a new instance of Rack.



8
9
10
# File 'lib/speedshop/cloudwatch/rack.rb', line 8

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/speedshop/cloudwatch/rack.rb', line 12

def call(env)
  begin
    queue_time = Observations::Rack.request_queue_time(env)
    MetricMapper.instance.report(metric: :RequestQueueTime, value: queue_time) if queue_time
  rescue => e
    Speedshop::Cloudwatch.log_error("Failed to collect Rack metrics: #{e.message}", e)
  end
  @app.call(env)
end