Class: RailsPerformance::Rails::Middleware
- Inherits:
-
Object
- Object
- RailsPerformance::Rails::Middleware
- Defined in:
- lib/rails_performance/rails/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
4 5 6 |
# File 'lib/rails_performance/rails/middleware.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rails_performance/rails/middleware.rb', line 8 def call(env) @status, @headers, @response = @app.call(env) if !Thread.current[:in_rails_performance] && record = Thread.current["RP_request_info"] record[:status] ||= @status record[:request_id] = CurrentRequest.current.request_id # rand(500).times do |e| # finished = Time.now - rand(2000).minutes # record[:datetime] = finished.strftime(RailsPerformance::FORMAT) # record[:datetimei] = finished.to_i # record[:duration] = 50 + rand(100) + rand(50.0) + rand(e) # record[:db_runtime] = rand(50.0) # record[:view_runtime] = rand(50.0) # RP::Utils.log_request_in_redis(record) # end RP::Utils.log_trace_in_redis(CurrentRequest.current.request_id, CurrentRequest.current.storage) RP::Utils.log_request_in_redis(record) Thread.current["RP_request_info"] = nil CurrentRequest.cleanup end [@status, @headers, @response] end |