lib/stackprof/middleware.rb in stackprof-0.2.13 vs lib/stackprof/middleware.rb in stackprof-0.2.14
- old
+ new
@@ -11,16 +11,22 @@
Middleware.interval = options[:interval] || 1000
Middleware.raw = options[:raw] || false
Middleware.enabled = options[:enabled]
options[:path] = 'tmp/' if options[:path].to_s.empty?
Middleware.path = options[:path]
+ Middleware.metadata = options[:metadata] || {}
at_exit{ Middleware.save } if options[:save_at_exit]
end
def call(env)
enabled = Middleware.enabled?(env)
- StackProf.start(mode: Middleware.mode, interval: Middleware.interval, raw: Middleware.raw) if enabled
+ StackProf.start(
+ mode: Middleware.mode,
+ interval: Middleware.interval,
+ raw: Middleware.raw,
+ metadata: Middleware.metadata,
+ ) if enabled
@app.call(env)
ensure
if enabled
StackProf.stop
if @num_reqs && (@num_reqs-=1) == 0
@@ -29,10 +35,10 @@
end
end
end
class << self
- attr_accessor :enabled, :mode, :interval, :raw, :path
+ attr_accessor :enabled, :mode, :interval, :raw, :path, :metadata
def enabled?(env)
if enabled.respond_to?(:call)
enabled.call(env)
else