lib/breakers/uptime_middleware.rb in breakers-0.2.1 vs lib/breakers/uptime_middleware.rb in breakers-0.2.2
- old
+ new
@@ -47,10 +47,12 @@
raise Breakers::OutageException.new(outage, service)
end
end
def handle_request(service:, request_env:, current_outage: nil)
+ start_time = Time.now
return @app.call(request_env).on_complete do |response_env|
+ response_env[:duration] = Time.now - start_time
if response_env.status >= 500
handle_error(
service: service,
request_env: request_env,
response_env: response_env,