Class: Rack::Stackprof
- Inherits:
-
Object
- Object
- Rack::Stackprof
- Defined in:
- lib/rack/stackprof/version.rb,
lib/rack/stackprof.rb
Constant Summary collapse
- VERSION =
'0.2.0'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Stackprof
constructor
A new instance of Stackprof.
Constructor Details
#initialize(app, options = {}) ⇒ Stackprof
Returns a new instance of Stackprof.
5 6 7 8 9 10 11 |
# File 'lib/rack/stackprof.rb', line 5 def initialize(app, = {}) @app = app @profile_interval_seconds = .fetch(:profile_interval_seconds) @sampling_interval_microseconds = .fetch(:sampling_interval_microseconds) @last_profiled_at = nil StackProf::Middleware.path = .fetch(:result_directory) # for `StackProf::Middleware.save` end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rack/stackprof.rb', line 13 def call(env) # Profile every X seconds (not everytime) to prevent from consuming disk excessively profile_every(seconds: @profile_interval_seconds, env: env) do @app.call(env) end end |