Class: RailsPerformance::Rails::MiddlewareTraceStorerAndCleanup
- Inherits:
-
Object
- Object
- RailsPerformance::Rails::MiddlewareTraceStorerAndCleanup
- Defined in:
- lib/rails_performance/rails/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #call!(env) ⇒ Object
-
#initialize(app) ⇒ MiddlewareTraceStorerAndCleanup
constructor
A new instance of MiddlewareTraceStorerAndCleanup.
Constructor Details
#initialize(app) ⇒ MiddlewareTraceStorerAndCleanup
Returns a new instance of MiddlewareTraceStorerAndCleanup.
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 |
# File 'lib/rails_performance/rails/middleware.rb', line 8 def call(env) dup.call!(env) end |
#call!(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_performance/rails/middleware.rb', line 12 def call!(env) if %r{#{RailsPerformance.mount_at}}.match?(env["PATH_INFO"]) RailsPerformance.skip = true end @status, @headers, @response = @app.call(env) if !RailsPerformance.skip RailsPerformance::Models::TraceRecord.new( request_id: CurrentRequest.current.request_id, value: CurrentRequest.current.tracings ).save end CurrentRequest.cleanup [@status, @headers, @response] end |