lib/rack/stackprof.rb in rack-stackprof-0.2.0 vs lib/rack/stackprof.rb in rack-stackprof-0.2.1
- old
+ new
@@ -5,11 +5,11 @@
def initialize(app, options = {})
@app = app
@profile_interval_seconds = options.fetch(:profile_interval_seconds)
@sampling_interval_microseconds = options.fetch(:sampling_interval_microseconds)
@last_profiled_at = nil
- StackProf::Middleware.path = options.fetch(:result_directory) # for `StackProf::Middleware.save`
+ @result_directory = options.fetch(:result_directory) # for `StackProf::Middleware.save`
end
def call(env)
# Profile every X seconds (not everytime) to prevent from consuming disk excessively
profile_every(seconds: @profile_interval_seconds, env: env) do
@@ -34,10 +34,10 @@
yield
ensure
StackProf.stop
finished_at = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_microsecond)
- StackProf::Middleware.path = result_filename(env: env, duration_milliseconds: (finished_at - started_at) / 1000)
+ StackProf::Middleware.path = File.join(@result_directory, result_filename(env: env, duration_milliseconds: (finished_at - started_at) / 1000))
StackProf::Middleware.save
end
# ex: "stackprof-20171004_175816-41860-GET_v1_users-0308ms.dump"
def result_filename(env:, duration_milliseconds:)