Class: RailsMemoryProfiler::Middleware
- Inherits:
-
Object
- Object
- RailsMemoryProfiler::Middleware
- Defined in:
- lib/rails_memory_profiler/middleware.rb
Overview
Rack middleware that profiles each request and pushes a report into ReportStore. Registered automatically by the Engine initializer; you do not need to add it to the middleware stack manually.
Profiling is skipped when:
-
Configuration#enabled is
false -
the request path matches Configuration#ignore_paths or the engine mount path
-
the request is not selected by Configuration#sample_rate
Instance Method Summary collapse
-
#call(env) ⇒ Array
Profiles the request if applicable and delegates to the inner app.
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
12 13 14 15 16 17 |
# File 'lib/rails_memory_profiler/middleware.rb', line 12 def initialize(app) @app = app @request_count = 0 @detailed_count = 0 @mutex = Mutex.new end |
Instance Method Details
#call(env) ⇒ Array
Profiles the request if applicable and delegates to the inner app.
23 24 25 26 27 28 29 |
# File 'lib/rails_memory_profiler/middleware.rb', line 23 def call(env) return @app.call(env) unless RailsMemoryProfiler.config.enabled return @app.call(env) if ignored_path?(env["PATH_INFO"]) return @app.call(env) unless sample? profile(env) end |